HighDots Forums  

Special characters problem

Javascript JavaScript language (comp.lang.javascript)


Discuss Special characters problem in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
petedawn@gmail.com
 
Posts: n/a

Default Special characters problem - 11-02-2006 , 09:55 PM






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.


Reply With Quote
  #2  
Old   
scriptguru@gmail.com
 
Posts: n/a

Default Re: Special characters problem - 11-03-2006 , 04:32 AM







petedawn (AT) gmail (DOT) com wrote:
Quote:
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



Reply With Quote
  #3  
Old   
uoL
 
Posts: n/a

Default Re: Special characters problem - 11-03-2006 , 07:30 AM



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

scriptguru (AT) gmail (DOT) com wrote:
Quote:
petedawn (AT) gmail (DOT) com wrote:
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


Reply With Quote
  #4  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Special characters problem - 11-03-2006 , 09:22 AM



petedawn (AT) gmail (DOT) com wrote:

Quote:
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>
--

Martin Honnen
http://JavaScript.FAQTs.com/


Reply With Quote
  #5  
Old   
ASM
 
Posts: n/a

Default Re: Special characters problem - 11-03-2006 , 10:01 AM



uoL a écrit :
Quote:
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&>
--
ASM


Reply With Quote
  #6  
Old   
uoL
 
Posts: n/a

Default Re: Special characters problem - 11-03-2006 , 01:55 PM




It worked !! thanks !

ASM wrote:
Quote:
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.com...d87f1a7?hl=fr&
--
ASM


Reply With Quote
  #7  
Old   
Jim Land
 
Posts: n/a

Default Re: Special characters problem - 11-03-2006 , 08:20 PM



"uoL" <wmarcos (AT) gmail (DOT) com> wrote in news:1162557034.357432.293900
@f16g2000cwb.googlegroups.com:

Quote:
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? ...

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?


Reply With Quote
  #8  
Old   
ASM
 
Posts: n/a

Default Re: Special characters problem - 11-04-2006 , 08:49 AM



Jim Land a écrit :
Quote:
"uoL" <wmarcos (AT) gmail (DOT) com> wrote in news:1162557034.357432.293900
@f16g2000cwb.googlegroups.com:

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? ...


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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.