472,145 Members | 1,499 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Problem with special chars

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

Mar 13 '07 #1
2 4043
Lupus wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 13 '07 #2
Lupus wrote:
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! :)

--
Bart

Mar 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jonas Meurer | last post: by
6 posts views Thread by Horst Gutmann | last post: by
2 posts views Thread by Thorsten Viel | last post: by
8 posts views Thread by abhi147 | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.