Reading from the HTML DOM returns UTF-8 characters
Posted
by teehoo
on Stack Overflow
See other posts from Stack Overflow
or by teehoo
Published on 2010-05-20T22:33:04Z
Indexed on
2010/05/20
22:40 UTC
Read the original article
Hit count: 250
I have a contenteditable
div
where I'm reading individual characters and sending them off to a server (for more background this is similar to Google Wave where typing a character automatically sends it)
I was using a plain old html textfield
before and everything worked fine until I "upgraded" to a contenteditable div.
My problem is that now the characters are in UTF-8 format, which is causing some weird problems on the server that I would rather not debug. It would be much easier to force everything to be ASCII on the client side.
Is there any way to do this? I tried putting in a meta tag stating the html file is charset=ISO-8859-1
, but it doesnt seem to work. Reading from the div tag still returns UTF-8 codes. (One example is when I press space I get the pair 0xC2 0xA0
which corresponds to a "non-breaking white space"
© Stack Overflow or respective owner