/    Sign up×
Community /Pin to ProfileBookmark

Replacement of character

I am reading a text file with an ajax function. All’s well so far.

There appears to be a special character written to the file when the entry is created.
I assume it to the the apostrophe character (‘), but in the file it looks like 222
and in the screen display it looks like a blue-diamond with a question mark.
When I view it with an editor, it appears to be one (not 4) characters.

I am trying to replace the single character 222 with the apostrophe using:

[code]
tmp = str.replace(/[222]/g ,”‘”)
// have also tried this
// tmp = str.replace(/[\222]/g ,”‘”)
[/code]

but this does not seem to work as the odd display continues to appear.

I’m reading a UNIX text file if that makes a difference, but I don’t think so.

Any ideas how to replace the single character 222 with the apostrope?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Jul 14.2009 — Is it not xDE (x followed by 222 in hexadecimal) in regular expressions?
Copy linkTweet thisAlerts:
@JMRKERauthorJul 14.2009 — Thank you Declan1991, nice try, but that didn't seem to work either. ?

I'm not creating the text file. It is being done by a program called 'formmail.cgi' when the form is submitted.

The 222 in the file appears to be a single character when I move my cursor over it using 'vi' on the unix system.


I'm assuming the user enters the apostrophe character but it is being altered (?) by the cgi program when posted to the text file,

but this is just a guess.

The are some other characters put out there like ^M (again a single character when viewed)

and I can modify this to a 'n' using a command of str = str.replace(/^M/g,' ')

and this appears to work fine. I can create the ^M by pressing 'ctrl-V','ctrl-M' in that sequence

but I don't know how to create the 222 as a single character for the replacement match.

Is there a different forum that this question might be more appropriate for?

I put it here because I'm using JS to do the replacement.
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...