StudioWorks
StudioWorks

Reputation: 493

How to remove funny characters in javascript?

On the following line:

alert ( "Apenas os números 0, 1, 3, 5, 7 e 9 são permitidos." );

it prints like this:

Apenas os n?meros 0, 1, 3, 5, 7 e 9 s?o permitidos. 

The problem is that the characters ú and ã are not showing correctly.

In HTML I did something like:

Apenas os números 0, 1, 3, 5, 7 e 9 são permitidos. 

and it worked, but I don't know what to do in JavaScript. What should I do to solve this? If it has anything to do with the problem i'm using UTF-8.

Thanks and sorry about the English.

Upvotes: 1

Views: 632

Answers (1)

Olical
Olical

Reputation: 41452

Javascript always prints in UTF-16 no matter what the HTML is set to, try to find the hex decimal values of those characters.

Then show them like this:

\uXXXX

Where XXXX are the 2 hexavalues of the character.

For example:

alert("\u05D0");

Upvotes: 1

Related Questions