Special characters problem

P

petedawn

hi guys,

based on users button press i am passing the following to my javascript
function, test('é'). and within my javascript i have this
function test(x) which processes this input.

now i am comparing this input using this, if ((x == "é")) {
alert ('eacute clicked') }, but i am unable to capture this for some
reason. everything else works. except special characters. btw i am
using english operating system.

has anybody else has had this problem, and can someone suggest a fix.

thanks.
 
S

scriptguru

hi guys,

based on users button press i am passing the following to my javascript
function, test('é'). and within my javascript i have this
function test(x) which processes this input.

now i am comparing this input using this, if ((x == "é")) {
alert ('eacute clicked') }, but i am unable to capture this for some
reason. everything else works. except special characters. btw i am
using english operating system.

has anybody else has had this problem, and can someone suggest a fix.

thanks.

try to insert "alert(x)" before that "if" and you will see why
x=="é" is false
 
U

uoL

hi,
I have a similar problem .. I use spanish language and i need to use
both question marks (¿?) and when i put ¿ into an alert .. alert
('¿') it shows this one '?' so a question that should be like this
¿desea activar? is displayed like this ?desea activar? ... I tried
with ¿ but it doesn't work ..

thanks
 
M

Martin Honnen

based on users button press i am passing the following to my javascript
function, test('é'). and within my javascript i have this
function test(x) which processes this input.

now i am comparing this input using this, if ((x == "é")) {
alert ('eacute clicked') }, but i am unable to capture this for some
reason. everything else works. except special characters. btw i am
using english operating system.

How about showing us the relevant code, meaning the markup of the button
and its event handlers, the function.

I suspect you have e.g.
<input type="button" onclick="test('&eacute;')"
which means the HTML parser dereferences the entity reference &eacute;
to the character é.

Then your function is defined inside of a <script
type="text/javascript"> element e.g.
function test (x) {
if (x == "&eacute;")

Inside of the script element the HTML parser does not dereference HTML
entity references thus the JavaScript string comparison is e.g.
'é' == '&eacute;'
and those strings are obviously not the same.

So the solution is to compare e.g.
if (x == 'é')
at least as long as your calls to the function passing the argument with
HTML entity references are inside HTML event handler attributes like
onclick.

See <http://www.w3.org/TR/html4/types.html#h-6.2>
 
A

ASM

uoL a écrit :
hi,
I have a similar problem .. I use spanish language and i need to use
both question marks (¿?) and when i put ¿ into an alert .. alert
('¿') it shows this one '?' so a question that should be like this
¿desea activar? is displayed like this ?desea activar? ... I tried
with &iquest; but it doesn't work ..

è = \xe8
é = \xe9
¿ = \xBF
ò = \xF1
ó = \xF3

alert('\xbf heart ? Qu\xe9 ! Es el coraz\xf3n en espa\xf1ol !');

http://www.miakinen.net/vrac/charsets/
(wait loading ...)
You click a glyfe and you see on right pannels its different codes
specialy that 'hexa'

then to use this hexa in JS alerts, prompts ans so on :

\xYY where YY is hexa code of character

hexa table (not complete) :
<http://groups.google.fr/group/fr.comp.infosystemes.www.auteurs/msg/b5147e55ed87f1a7?hl=fr&>
 
U

uoL

It worked !! thanks !
uoL a écrit :

è = \xe8
é = \xe9
¿ = \xBF
ò = \xF1
ó = \xF3

alert('\xbf heart ? Qu\xe9 ! Es el coraz\xf3n en espa\xf1ol !');

http://www.miakinen.net/vrac/charsets/
(wait loading ...)
You click a glyfe and you see on right pannels its different codes
specialy that 'hexa'

then to use this hexa in JS alerts, prompts ans so on :

\xYY where YY is hexa code of character

hexa table (not complete) :
<http://groups.google.fr/group/fr.comp.infosystemes.www.auteurs/msg/b5147e55ed87f1a7?hl=fr&>
 
A

ASM

Jim Land a écrit :
alert('¿desea activar?'); shows exactly that, in FF 1.5 and IE 6.0.

What browser are you using, that doesn't show what you want?

All depends what headers are sent ... (charset and all that )
and if charset of encoding it in accordance with this of text editor.

Probably depends too if there is a doctype on the page
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top