[html5] How to test for cents currency symbol in javascript
Larry Martell
larry.martell at gmail.com
Sun May 25 12:10:31 PDT 2014
Hi Bjartur-
On Sat, May 24, 2014 at 8:39 AM, Bjartur Thorlacius
<svartman95 at gmail.com> wrote:
> 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
This was the problem! I can't thank you enough! Once I saved my js
file as UFT-8 it started working perfectly.
FYI, I am on Linux and I am using vim, and the command was:
:w ++enc=uft-8
Thanks again!
-larry
More information about the Help
mailing list