Hex characters in JavaScript

A

Andy

Not strictly Front Page but anyway ...

I need to examine a string from an html form text area
field and check for certain characters using the
string.substring(a,b) function or similar.

If the characters are normal like "a" then OK but if a
line throw character is found, I need to replace it with a
normal character like "+".

I guess I need to do some stuff with hex etc.

Something like, say, for the 3rd character of the string :-

linethrowchar = "#0C"; // if this is correct?

if (fieldstring.substring(2,1) == linethrowchar)
{fieldstring.substring(2,1) = "+";}

You get the idea anyway ... does it need eval or something?
When I look around about Hex it always seems to be
something about colors.
 
M

MD WebsUnlimited.com

Hi Andy,

Use a hex literal of the form '0x0C' which is a carriage return character
which is the same as '\r' I've never heard either call a line throw
character.

If the goal is to replace the line feed character then use

string.replace('\r','~') where string is the string var.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top