Re: How many bytes does charCodeAt return?
- From: Thomas 'PointedEars' Lahn <PointedEars@xxxxxx>
- Date: Sun, 13 Sep 2009 07:35:47 +0200
Johannes Baagoe wrote:
Lasse Reichstein Nielsen :
That's probably a problem with the interpretation of input (or it's
just a bug).
It appears to be a bug in the interpretation of input.
Yes, as can be seen here. You have posted a Unicode EURO SIGN character
(U+20AC) encoded with UTF-8. For some reason Lasse's client does not appear
to support UTF-8 (or was the wrong encoding chosen intentionally here?); as
he replied to your posting, he encoded it with and declared it (in the
Content-Type header) as ISO-8859-1. As a result, the single Unicode
character was transformed, for display, into three ISO-8859-1 characters
which code points in ISO-8859-1 correspond to the values of the three UTF-8
code units required to encode the character, and which corresponds to the
number 3 you are seeing in your JavaScript shell.
See also <http://people.w3.org/rishida/tools/conversion>.
If you create the string directly from ASCII JavaScript, what does it
print? I.e.,
var euroecu = String.fromCharCode(0x20ac, 0x20a0);
print(euroecu.length); // expect 2
Thanks. I did not know that String.fromCharCode() supports an arbitrary
number of arguments; but ES3F section 15.5.3.2 agrees.
On a side note, though, JFTR: ECU (European Currency Unit) has been the
virtual currency (German: Buchgeld) in the European Community, later
European Union, from 1979 CE until including 1998. It is not to be confused
with the Euro, which is the name and sign of the official currency of the
European Economic and Monetary Union (EEMU) since 1999-01-01 (virtual) and
2002-01-01 (cash).
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
.
- References:
- How many bytes does charCodeAt return?
- From: Johannes Baagoe
- Re: How many bytes does charCodeAt return?
- From: Johannes Baagoe
- Re: How many bytes does charCodeAt return?
- From: Thomas 'PointedEars' Lahn
- Re: How many bytes does charCodeAt return?
- From: Johannes Baagoe
- Re: How many bytes does charCodeAt return?
- From: Lasse Reichstein Nielsen
- Re: How many bytes does charCodeAt return?
- From: Johannes Baagoe
- How many bytes does charCodeAt return?
- Prev by Date: Re: David Mark's AddEvent (was: Re-enable disabled form elements when user goes 'Back')
- Next by Date: Re: EcmaScript: delete operator
- Previous by thread: Re: How many bytes does charCodeAt return?
- Next by thread: Re: How many bytes does charCodeAt return?
- Index(es):
Relevant Pages
|
Loading