[html5] How to test for cents currency symbol in javascript

Bjartur Thorlacius svartman95 at gmail.com
Sat May 24 05:39:11 PDT 2014

Larry Martell:
> In my program I do this:
> ax = (a[0][0] == '¢');
> When my program run ax is False. But from the console it evaluates to True:
> Can anyone explain this odd inconsistency and tell me how I can test
> for the cents character?
The inconsistency may be stem from a character encoding issue. Have you 
tried saving your JavaScript in a different encoding, say UTF-8 or 
ISO-8859-1 (Latin-1)? Most likely, you're saving the file as a 
Windows-1252 text file, but your browser is trying to interpret it as UTF-8.

In your text editor, try File->Save As and select a different character 
encoding. On Mac OS X and other unices, you can inspect the character 
encoding of a file with a command called file(1). Try typing „file 
Desktop/Folder/file.js“ without the quotes (substituting the filename) 
into the command line of a terminal.

Bjartur Thorlacius

P.S. The Vim command, if you happen to be using that text editor.
:w ++encoding=UTF-8

More information about the Help mailing list