Problem with special chars

L

Lupus

Hi everyone,

I've got a problem with a piece of javascript code which parses a
string. The problem occurs when the string contains some special
characters like é, è, ü...

There are 2 symptoms
The string shows up incomplete, i.e. Günther => G? or sometime I have
javascript error :
"End of file reached in invalid state for current encoding"

The string is used to populate a select box, so converting the special
chars into HTML entities didn't work...

Could anyone help me out ?


Thx!
Mathew
 
M

Martin Honnen

Lupus said:
I've got a problem with a piece of javascript code which parses a
string. The problem occurs when the string contains some special
characters like é, è, ü...

There are 2 symptoms
The string shows up incomplete, i.e. Günther => G? or sometime I have
javascript error :
"End of file reached in invalid state for current encoding"

Well make sure you choose an appropriate encoding for your files and use
a text editor which saves in that encoding, then make sure the HTTP
server serves the files indicating the encoding.
 
B

Bart Van der Donck

Lupus said:
I've got a problem with a piece of javascript code which
parses a string. The problem occurs when the string contains
some special characters like é, è, ü...

There are 2 symptoms
The string shows up incomplete, i.e. Günther => G? or sometime
I have javascript error :
"End of file reached in invalid state for current encoding"

The string is used to populate a select box, so converting the
special chars into HTML entities didn't work...

One possible solution which allows you to use all characters that a
browser can display, without needing to save them as such:

alert('\u00e8\u00e9\u00fc')

The tables at http://unicode.coeurlumiere.com/ give you every code
point that the javascript engine supports (65535 combinations in hex).
Just replace the last zero of the left code by the character in the
upper row, like eg \u0079 for 'y'.

With this approach you can always save your programming code in ASCII,
which is a full guarantee to never have this kind of problems. Quick
and dirty! :)
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top