Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #23961

Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do?

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do?
Date 2014-04-26 18:20 +0200
Organization PointedEars Software (PES)
Message-ID <1606411.7n5RFCq9OI@PointedEars.de> (permalink)
References <9521275e-7eb0-4d31-adc0-76044b3d33e1@googlegroups.com> <535a21aa$0$6703$9b4e6d93@newsspool2.arcor-online.net> <2732090.DMPj7CqQq3@PointedEars.de> <gUP6v.59558$IN1.5722@en-nntp-15.dc1.easynews.com>

Show all headers | View raw


Richard Damon wrote:

> On 4/25/14, 6:42 AM, Thomas 'PointedEars' Lahn wrote:
>>   2. Without a BOM, a text editor cannot tell UTF-8 encoding from
>>      a one-byte encoding like ISO-8859-1.  One can support UTF-8-capable
>>      editors by tagging source code.  For example, for Vim you can insert
>>      (at the beginning or the end; I recommend the latter to preserve
>>      line numbers) 
> 
> One nit, despite that many software packages

… as required at least by all Web standards (to be) [1][2] …

> try to make the inclusion of a BOM indicate UTF-8, it does nothing of the
> sorts. The byte sequence 0xEF 0xBB 0xBF (the representation of BOM in
> UTF-8) is a perfectly valid ISO-8859-1 character sequence (perhaps
> unlikely, but possible and legal). The BOM can be used to distinguish
> between UTF-8, UTF-16, and UTF-32, but that is not normally the thing that
> needs determining.

The UTF-8 code sequence for a Byte Order Mark (BOM), interpreted as one-byte 
characters, e.g. “” in ISO-8859-1, is a *syntax error* in ECMAScript and 
other languages (programming languages, formatting languages, and markup 
languages alike) when appearing at the beginning of source code.  Thus, 
there is no reasonable ambiguity: it is assumed that it is more probable 
that the author wanted to include a BOM in syntactically valid source code 
in order to mark the source code as Unicode text than to produce 
syntactically invalid source code.

For that reason, code sequences for a BOM are treated as whitespace in 
ECMAScript. [3]  (However, AFAICS there is no requirement that a conforming 
implementation must treat source code with a UTF-8 BOM as UTF-8; this 
includes string literals.)

> Also, a BOM is totally unneeded for a UTF-8 file. When saving data in
> UTF-16 or UCS-2, the BOM can help distinguish between UTF-16LE and
> UTF-16BE, but UTF-8 doesn't have this issue (there is only one possible
> byte order for the stream).

Fallacy: Denying the antecedent.

I have _not_ claimed that it was needed.  I have said that *without* a BOM 
it is *not* possible for a parser to tell whether the source code is UTF-8-
encoded.  Which, as I also have said, requires character encoding 
declaration by other means; namely, a suitable “Content-Type” header field 
value.  Thus, I am *well aware* that a BOM is _not_ needed.

> Lastly, those programs that want to add the BOM to indicate UTF-8
> encoding are broken in that there are some types of files where the
> addition of the BOM at the beginning of the file may well break the
> functionality of the file (particularly for scripts).

Because of the above, I know to avoid using the BOM for UTF-8 because it 
causes problems with PHP scripts (_not_ scripts in general).  In particular, 
I use an editor/IDE (Eclipse JSDT) that does not generate a BOM but still 
supports UTF-8-encoded source code.

Congratulations, you have managed to miss the point entirely while posting a 
lot of nonsense and FUD.

___________
[1] <http://www.w3.org/TR/2008/REC-xml-20081126/#charencoding>
[2] <http://encoding.spec.whatwg.org/#specification-hooks>
[3] <http://ecma-international.org/ecma-262/5.1/#sec-7.2>
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? jonas.thornvall@gmail.com - 2014-04-25 01:43 -0700
  Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? Martin Honnen <mahotrash@yahoo.de> - 2014-04-25 10:49 +0200
    Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? jonas.thornvall@gmail.com - 2014-04-25 02:30 -0700
    Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-25 12:42 +0200
      Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? jonas.thornvall@gmail.com - 2014-04-25 21:26 -0700
      Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? jonas.thornvall@gmail.com - 2014-04-25 21:38 -0700
      Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? jonas.thornvall@gmail.com - 2014-04-25 21:40 -0700
      Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? Richard Damon <Richard@Damon-Family.org> - 2014-04-26 11:02 -0400
        Re: I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-26 18:20 +0200

csiph-web