PDA

View Full Version : Accents in Javascript



ajarantes
Feb 4th, 2003, 05:23 PM
If I put this command:

==> w i n d o w . d o c u m e n t . w r i t e l n ( " A t e n & c c e d i l ; & a t i l d e ; o " ) ;

the result is the expected, i.e., A t e n ç ã o

on the other hand, if I use this other command:

==> w i n d o w . a l e r t ( " A t e n & c c e d i l ; & a t i l d e ; o " ) ;

it gives me back exactly what I wrote. It doesn't seem to interpret the & c c e d i l ; nor the & a t i l d e ;. The result is A t e n & c c e d i l ; & a t i l d e ; o

Does anybody know why?

beetle
Feb 4th, 2003, 06:21 PM
because &ampccedil; etc are HTML entities, and an alert() doesn't render HTML.

You'll need to enter the actual character into the HTML using the ALT key plus the ASCII value, like alt+0231 for

scroots
Feb 4th, 2003, 06:49 PM
i would change it to
var text
text='you text here accents and all'
alert(text)

if the above or something similair doesn`t work it is probably to do with the way the browser is designed.
As & c c e d i l ; & a t i l d e ; id the ISO some sort of standard stuff for HTML code.

scroots