[thelist] French characters in JavaScript

J.J.SOLARI jjsolari at pobox.com
Wed Feb 18 05:14:50 CST 2004


> Date: Tue, 17 Feb 2004 11:22:04 -0500 From: Steve Bissonnette
> <steve at plankdesign.com>
> 
> Hi -
> 
> I'm trying to remember how to do French characters (=E9=E2=C9 etc.)
> in a JavaScript alert. Can anyone help me out with this ?
> 
> 
> <script type=3D"text/javascript" language=3D"Javascript">
> 
> alert('=E9=EE=E5=E1=E8=C8=C2');
> 
> </script>
> 
> 
> Escaping them doesn't work - neither does using the entity encoding
> -- I think it's Unicode - but them I end up with tons of problems
> with PHP.

Steve,

You need to use octal or hexadecimal character codes.

For example, to display the following message in a JS alert:

msg = " Hé, vous là-bas ! " ( " H&eacute;, vous l&agrave;-bas ! ") ;

You would do:

alert( " H\u00E9, vous l\u00E0-bas ! " )

This should work with any JavaScript engine.

You might use a handy character converter at:
<http://www.saila.com/usage/tips/examples/special_characters.html>

Now, if Unicode characters are more a problem thant a solution, you may
consider using a charset declaration like this:

<script type="text/javascript" charset="iso-8859-1">
alert( msg );
</script>

But support is not guaranteed.

hih,

JJS. 


More information about the thelist mailing list