Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23937 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2014-04-25 01:43 -0700 |
| Last post | 2014-04-26 18:20 +0200 |
| Articles | 9 — 4 participants |
Back to article view | Back to comp.lang.javascript
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
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2014-04-25 01:43 -0700 |
| Subject | I try to write out sigma sign in javascript on a canvas, but HTML encoding do not work, how should i do? |
| Message-ID | <9521275e-7eb0-4d31-adc0-76044b3d33e1@googlegroups.com> |
I've tried to assign string func both with and without enclosing brackets. But it just write out the ASCII not the encoding on canvas. So HTML encode chars do not work on canvas. How can i solve this?
//Not working arr[j].func = ("∑(1 ≤ n <"+n+")n?");
//Not working arr[j].func = "∑(1 ≤ n <"+n+")n?";
[toc] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2014-04-25 10:49 +0200 |
| Message-ID | <535a21aa$0$6703$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #23937 |
jonas.thornvall@gmail.com wrote:
> I've tried to assign string func both with and without enclosing brackets. But it just write out the ASCII not the encoding on canvas. So HTML encode chars do not work on canvas. How can i solve this?
>
> //Not working arr[j].func = ("∑(1 ≤ n <"+n+")n?");
> //Not working arr[j].func = "∑(1 ≤ n <"+n+")n?";
You should be able to use any Unicode character literally in your script
code as long as you use an Unicode encoding like UTF-8 for your script
files e.g. so use
arr[j].func = "∑(1 ≤ n <100)n?";
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2014-04-25 02:30 -0700 |
| Message-ID | <bf21c0d6-7a89-478a-8b67-c9a78c411b5e@googlegroups.com> |
| In reply to | #23938 |
Den fredagen den 25:e april 2014 kl. 10:49:45 UTC+2 skrev Martin Honnen:
> jonas.thornvall@gmail.com wrote:
>
> > I've tried to assign string func both with and without enclosing brackets. But it just write out the ASCII not the encoding on canvas. So HTML encode chars do not work on canvas. How can i solve this?
>
> >
>
> > //Not working arr[j].func = ("∑(1 ≤ n <"+n+")n?");
>
> > //Not working arr[j].func = "∑(1 ≤ n <"+n+")n?";
>
>
>
> You should be able to use any Unicode character literally in your script
>
> code as long as you use an Unicode encoding like UTF-8 for your script
>
> files e.g. so use
>
>
>
> arr[j].func = "∑(1 ≤ n <100)n?";
I am not sure what you mean i can hardly write sigma sign in microsoft notes, and the sign you just wrote is the HTML i did try that will not work on canvas for me.
I have changed unicode in http meta equiv to UTF-8.
http://web.comhem.se/jonasth/prime0.9951/div.html
The function doing the print to Array is square_checked()
If anyone could help me resolve this i would be greatful.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-04-25 12:42 +0200 |
| Message-ID | <2732090.DMPj7CqQq3@PointedEars.de> |
| In reply to | #23938 |
Martin Honnen wrote:
> jonas.thornvall@gmail.com wrote:
>> I've tried to assign string func both with and without enclosing
>> brackets. But it just write out the ASCII not the encoding on canvas. So
>> HTML encode chars do not work on canvas. How can i solve this?
>>
>> //Not working arr[j].func = ("∑(1 ≤ n <"+n+")n?");
>> //Not working arr[j].func = "∑(1 ≤ n <"+n+")n?";
>
> You should be able to use any Unicode character literally in your script
> code as long as you use an Unicode encoding like UTF-8 for your script
> files e.g. so use
>
> arr[j].func = "∑(1 ≤ n <100)n?";
[I would type those using AltGr+Shift+S and Shift+AltGr, “<”, “=” :)]
True. However, two things one needs to be aware of:
1. You also need to serve those files declaring the used character
encoding in the Content-Type header field value because ECMAScript
has no way of telling the parser the used character encoding yet,
and there is no default encoding ubiquitously implemented.
A possibility is to add
<IfModule mime_module>
AddType text/javascript;charset=utf-8 .js
</IfModule>
to your .htaccess file if you are using an httpd-compatible
server like Apache.
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)
/* vim:set fileencoding=utf-8 */
which removes the need to issue the command “:set encoding=utf-8”
manually or use “set encoding=utf-8” in one’s vimrc.
Although all my source code is UTF-8 encoded by default (Eclipse
preference), I have begun to tag it like that when I use characters
whose code point is beyond U+007F (characters not in US-ASCII), for
example in JSX:math/complex.js [1]
If using a Unicode encoding, thus using Unicode characters verbatim, is not
an option for you, ECMAScript supports Unicode escape sequences [2]:
arr[j].func = "\u2211(1 \u2264 n <100)n?"; // ¹
Constants or constant-like variables or properties can be used to make such
code easier readable, especially if symbols are used repeatedly:
/* you may use “const” if your target implementations support it */
var CH_SUM = "\u2211";
var CH_LTE = "\u2264";
arr[j].func = CH_SUM + "(1 " + CH_LTE + " n <100)n?";
One should be aware, however, that using escape sequences instead of plain
characters increases the file size (here: 6 or more instead of up to four
8-bit bytes), and requires more parsing, therefore increases the time it
takes to load a document. That applies both to ECMAScript and markup
documents, like HTML.
If you are using HTML5 or XHTML, consider using MathML. Gecko-based
browsers support MathML well [3]; recently a user stylesheet has been
proposed for working around Chromium’s currently disabled MathML
support. [4]
_______
¹ I have obtained this using
"∑(1 ≤ n <100)n?".split("").map(function (char) {
if (char.charCodeAt(0) > 0x7F)
{
return "\\u" + char.charCodeAt(0).toString(16);
}
else
{
return char;
}
}).join("")
(as a one-liner with another identifier) on the script console. It can
be improved to give the correct escape sequence for characters below
U+1000, too. See also <http://mothereff.in/js-escapes> by Mathias Bynens
(@mathias).
[1]
<http://PointedEars.de/wsvn/JSX?op=comp&compare[]=/trunk/@533&compare[]=/trunk/@534>
[2] <http://ecma-international.org/ecma-262/5.1/#sec-7.8.4>
[3] Testcases:
<http://pointedears.de/markup/equation2.html>
<http://pointedears.de/markup/equation2.xhtml>
<http://pointedears.de/markup/xml/SVG/doppler>
[4] <https://code.google.com/p/chromium/issues/detail?id=152430#c94>
--
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.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2014-04-25 21:26 -0700 |
| Message-ID | <6eed4810-5d9b-4d56-bd0d-59ec3c512652@googlegroups.com> |
| In reply to | #23940 |
Den fredagen den 25:e april 2014 kl. 12:42:43 UTC+2 skrev Thomas 'PointedEars' Lahn:
> Martin Honnen wrote:
>
>
>
> > jonas.thornvall@gmail.com wrote:
>
> >> I've tried to assign string func both with and without enclosing
>
> >> brackets. But it just write out the ASCII not the encoding on canvas. So
>
> >> HTML encode chars do not work on canvas. How can i solve this?
>
> >>
>
> >> //Not working arr[j].func = ("∑(1 ≤ n <"+n+")n?");
>
> >> //Not working arr[j].func = "∑(1 ≤ n <"+n+")n?";
>
> >
>
> > You should be able to use any Unicode character literally in your script
>
> > code as long as you use an Unicode encoding like UTF-8 for your script
>
> > files e.g. so use
>
> >
>
> > arr[j].func = "∑(1 ≤ n <100)n?";
>
>
>
> [I would type those using AltGr+Shift+S and Shift+AltGr, “<”, “=” :)]
>
>
>
> True. However, two things one needs to be aware of:
>
>
>
> 1. You also need to serve those files declaring the used character
>
> encoding in the Content-Type header field value because ECMAScript
>
> has no way of telling the parser the used character encoding yet,
>
> and there is no default encoding ubiquitously implemented.
>
>
>
> A possibility is to add
>
>
>
> <IfModule mime_module>
>
> AddType text/javascript;charset=utf-8 .js
>
> </IfModule>
>
>
>
> to your .htaccess file if you are using an httpd-compatible
>
> server like Apache.
>
>
>
> 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)
>
>
>
> /* vim:set fileencoding=utf-8 */
>
>
>
> which removes the need to issue the command “:set encoding=utf-8”
>
> manually or use “set encoding=utf-8” in one’s vimrc.
>
>
>
> Although all my source code is UTF-8 encoded by default (Eclipse
>
> preference), I have begun to tag it like that when I use characters
>
> whose code point is beyond U+007F (characters not in US-ASCII), for
>
> example in JSX:math/complex.js [1]
>
>
>
> If using a Unicode encoding, thus using Unicode characters verbatim, is not
>
> an option for you, ECMAScript supports Unicode escape sequences [2]:
>
>
>
> arr[j].func = "\u2211(1 \u2264 n <100)n?"; // ¹
>
>
>
> Constants or constant-like variables or properties can be used to make such
>
> code easier readable, especially if symbols are used repeatedly:
>
>
>
> /* you may use “const” if your target implementations support it */
>
> var CH_SUM = "\u2211";
>
> var CH_LTE = "\u2264";
>
>
>
> arr[j].func = CH_SUM + "(1 " + CH_LTE + " n <100)n?";
>
>
>
> One should be aware, however, that using escape sequences instead of plain
>
> characters increases the file size (here: 6 or more instead of up to four
>
> 8-bit bytes), and requires more parsing, therefore increases the time it
>
> takes to load a document. That applies both to ECMAScript and markup
>
> documents, like HTML.
>
>
>
> If you are using HTML5 or XHTML, consider using MathML. Gecko-based
>
> browsers support MathML well [3]; recently a user stylesheet has been
>
> proposed for working around Chromium’s currently disabled MathML
>
> support. [4]
>
>
>
> _______
>
> ¹ I have obtained this using
>
>
>
> "∑(1 ≤ n <100)n?".split("").map(function (char) {
>
> if (char.charCodeAt(0) > 0x7F)
>
> {
>
> return "\\u" + char.charCodeAt(0).toString(16);
>
> }
>
> else
>
> {
>
> return char;
>
> }
>
> }).join("")
>
>
>
> (as a one-liner with another identifier) on the script console. It can
>
> be improved to give the correct escape sequence for characters below
>
> U+1000, too. See also <http://mothereff.in/js-escapes> by Mathias Bynens
>
> (@mathias).
>
>
>
>
>
> [1]
>
> <http://PointedEars.de/wsvn/JSX?op=comp&compare[]=/trunk/@533&compare[]=/trunk/@534>
>
> [2] <http://ecma-international.org/ecma-262/5.1/#sec-7.8.4>
>
> [3] Testcases:
>
> <http://pointedears.de/markup/equation2.html>
>
> <http://pointedears.de/markup/equation2.xhtml>
>
> <http://pointedears.de/markup/xml/SVG/doppler>
>
> [4] <https://code.google.com/p/chromium/issues/detail?id=152430#c94>
>
> --
>
> 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.
This is all a bit over my head right now Thomas but the characters is decoded by the local script enginge e.g the browser?
How could the editor matter, i simply do not understand that?
Are you saying the editor have ability to write out and save a character set that is outside what (for example) notepad can?
If so will an ordinary browser like Chrome, Firefox, Opera, IExplorer be able to handle it?
What HTML tage, javacripts declarations is needed for the browser to load the extended character set?
And what happens if someone tries to look at the source code from inside the browser or in notepad, will the character encoded with the extended code set show up as bad format or what?
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2014-04-25 21:38 -0700 |
| Message-ID | <273dc41b-38f1-42f6-994e-16fe941ff2c4@googlegroups.com> |
| In reply to | #23940 |
Den fredagen den 25:e april 2014 kl. 12:42:43 UTC+2 skrev Thomas 'PointedEars' Lahn:
> Martin Honnen wrote:
>
>
>
> > jonas.thornvall@gmail.com wrote:
>
> >> I've tried to assign string func both with and without enclosing
>
> >> brackets. But it just write out the ASCII not the encoding on canvas. So
>
> >> HTML encode chars do not work on canvas. How can i solve this?
>
> >>
>
> >> //Not working arr[j].func = ("∑(1 ≤ n <"+n+")n?");
>
> >> //Not working arr[j].func = "∑(1 ≤ n <"+n+")n?";
>
> >
>
> > You should be able to use any Unicode character literally in your script
>
> > code as long as you use an Unicode encoding like UTF-8 for your script
>
> > files e.g. so use
>
> >
>
> > arr[j].func = "∑(1 ≤ n <100)n?";
>
>
>
> [I would type those using AltGr+Shift+S and Shift+AltGr, “<”, “=” :)]
>
>
>
> True. However, two things one needs to be aware of:
>
>
>
> 1. You also need to serve those files declaring the used character
>
> encoding in the Content-Type header field value because ECMAScript
>
> has no way of telling the parser the used character encoding yet,
>
> and there is no default encoding ubiquitously implemented.
>
>
>
> A possibility is to add
>
>
>
> <IfModule mime_module>
>
> AddType text/javascript;charset=utf-8 .js
>
> </IfModule>
>
>
>
> to your .htaccess file if you are using an httpd-compatible
>
> server like Apache.
>
>
>
> 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)
>
>
>
> /* vim:set fileencoding=utf-8 */
>
>
>
> which removes the need to issue the command “:set encoding=utf-8”
>
> manually or use “set encoding=utf-8” in one’s vimrc.
>
>
>
> Although all my source code is UTF-8 encoded by default (Eclipse
>
> preference), I have begun to tag it like that when I use characters
>
> whose code point is beyond U+007F (characters not in US-ASCII), for
>
> example in JSX:math/complex.js [1]
>
>
>
> If using a Unicode encoding, thus using Unicode characters verbatim, is not
>
> an option for you, ECMAScript supports Unicode escape sequences [2]:
>
>
>
> arr[j].func = "\u2211(1 \u2264 n <100)n?"; // ¹
>
>
>
> Constants or constant-like variables or properties can be used to make such
>
> code easier readable, especially if symbols are used repeatedly:
>
>
>
> /* you may use “const” if your target implementations support it */
>
> var CH_SUM = "\u2211";
>
> var CH_LTE = "\u2264";
>
>
>
> arr[j].func = CH_SUM + "(1 " + CH_LTE + " n <100)n?";
>
>
>
> One should be aware, however, that using escape sequences instead of plain
>
> characters increases the file size (here: 6 or more instead of up to four
>
> 8-bit bytes), and requires more parsing, therefore increases the time it
>
> takes to load a document. That applies both to ECMAScript and markup
>
> documents, like HTML.
>
>
>
> If you are using HTML5 or XHTML, consider using MathML. Gecko-based
>
> browsers support MathML well [3]; recently a user stylesheet has been
>
> proposed for working around Chromium’s currently disabled MathML
>
> support. [4]
>
>
>
> _______
>
> ¹ I have obtained this using
>
>
>
> "∑(1 ≤ n <100)n?".split("").map(function (char) {
>
> if (char.charCodeAt(0) > 0x7F)
>
> {
>
> return "\\u" + char.charCodeAt(0).toString(16);
>
> }
>
> else
>
> {
>
> return char;
>
> }
>
> }).join("")
>
>
>
> (as a one-liner with another identifier) on the script console. It can
>
> be improved to give the correct escape sequence for characters below
>
> U+1000, too. See also <http://mothereff.in/js-escapes> by Mathias Bynens
>
> (@mathias).
>
>
>
>
>
> [1]
>
> <http://PointedEars.de/wsvn/JSX?op=comp&compare[]=/trunk/@533&compare[]=/trunk/@534>
>
> [2] <http://ecma-international.org/ecma-262/5.1/#sec-7.8.4>
>
> [3] Testcases:
>
> <http://pointedears.de/markup/equation2.html>
>
> <http://pointedears.de/markup/equation2.xhtml>
>
> <http://pointedears.de/markup/xml/SVG/doppler>
>
> [4] <https://code.google.com/p/chromium/issues/detail?id=152430#c94>
>
> --
>
> 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.
This is my meta tags now.
<meta http-Equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="300">
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2014-04-25 21:40 -0700 |
| Message-ID | <d54e9707-b068-4705-a3b0-d6ed6c3cc83d@googlegroups.com> |
| In reply to | #23940 |
Den fredagen den 25:e april 2014 kl. 12:42:43 UTC+2 skrev Thomas 'PointedEars' Lahn:
> Martin Honnen wrote:
>
>
>
> > jonas.thornvall@gmail.com wrote:
>
> >> I've tried to assign string func both with and without enclosing
>
> >> brackets. But it just write out the ASCII not the encoding on canvas. So
>
> >> HTML encode chars do not work on canvas. How can i solve this?
>
> >>
>
> >> //Not working arr[j].func = ("∑(1 ≤ n <"+n+")n?");
>
> >> //Not working arr[j].func = "∑(1 ≤ n <"+n+")n?";
>
> >
>
> > You should be able to use any Unicode character literally in your script
>
> > code as long as you use an Unicode encoding like UTF-8 for your script
>
> > files e.g. so use
>
> >
>
> > arr[j].func = "∑(1 ≤ n <100)n?";
>
>
>
> [I would type those using AltGr+Shift+S and Shift+AltGr, “<”, “=” :)]
>
>
>
> True. However, two things one needs to be aware of:
>
>
>
> 1. You also need to serve those files declaring the used character
>
> encoding in the Content-Type header field value because ECMAScript
>
> has no way of telling the parser the used character encoding yet,
>
> and there is no default encoding ubiquitously implemented.
>
>
>
> A possibility is to add
>
>
>
> <IfModule mime_module>
>
> AddType text/javascript;charset=utf-8 .js
>
> </IfModule>
>
>
>
> to your .htaccess file if you are using an httpd-compatible
>
> server like Apache.
>
>
>
> 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)
>
>
>
> /* vim:set fileencoding=utf-8 */
>
>
>
> which removes the need to issue the command “:set encoding=utf-8”
>
> manually or use “set encoding=utf-8” in one’s vimrc.
>
>
>
> Although all my source code is UTF-8 encoded by default (Eclipse
>
> preference), I have begun to tag it like that when I use characters
>
> whose code point is beyond U+007F (characters not in US-ASCII), for
>
> example in JSX:math/complex.js [1]
>
>
>
> If using a Unicode encoding, thus using Unicode characters verbatim, is not
>
> an option for you, ECMAScript supports Unicode escape sequences [2]:
>
>
>
> arr[j].func = "\u2211(1 \u2264 n <100)n?"; // ¹
>
>
>
> Constants or constant-like variables or properties can be used to make such
>
> code easier readable, especially if symbols are used repeatedly:
>
>
>
> /* you may use “const” if your target implementations support it */
>
> var CH_SUM = "\u2211";
>
> var CH_LTE = "\u2264";
>
>
>
> arr[j].func = CH_SUM + "(1 " + CH_LTE + " n <100)n?";
>
>
>
> One should be aware, however, that using escape sequences instead of plain
>
> characters increases the file size (here: 6 or more instead of up to four
>
> 8-bit bytes), and requires more parsing, therefore increases the time it
>
> takes to load a document. That applies both to ECMAScript and markup
>
> documents, like HTML.
>
>
>
> If you are using HTML5 or XHTML, consider using MathML. Gecko-based
>
> browsers support MathML well [3]; recently a user stylesheet has been
>
> proposed for working around Chromium’s currently disabled MathML
>
> support. [4]
>
>
>
> _______
>
> ¹ I have obtained this using
>
>
>
> "∑(1 ≤ n <100)n?".split("").map(function (char) {
>
> if (char.charCodeAt(0) > 0x7F)
>
> {
>
> return "\\u" + char.charCodeAt(0).toString(16);
>
> }
>
> else
>
> {
>
> return char;
>
> }
>
> }).join("")
>
>
>
> (as a one-liner with another identifier) on the script console. It can
>
> be improved to give the correct escape sequence for characters below
>
> U+1000, too. See also <http://mothereff.in/js-escapes> by Mathias Bynens
>
> (@mathias).
>
>
>
>
>
> [1]
>
> <http://PointedEars.de/wsvn/JSX?op=comp&compare[]=/trunk/@533&compare[]=/trunk/@534>
>
> [2] <http://ecma-international.org/ecma-262/5.1/#sec-7.8.4>
>
> [3] Testcases:
>
> <http://pointedears.de/markup/equation2.html>
>
> <http://pointedears.de/markup/equation2.xhtml>
>
> <http://pointedears.de/markup/xml/SVG/doppler>
>
> [4] <https://code.google.com/p/chromium/issues/detail?id=152430#c94>
>
> --
>
> 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.
One more thing this is for Canvas, i do know howto pipeout special characters as HTML on a page.
[toc] | [prev] | [next] | [standalone]
| From | Richard Damon <Richard@Damon-Family.org> |
|---|---|
| Date | 2014-04-26 11:02 -0400 |
| Message-ID | <gUP6v.59558$IN1.5722@en-nntp-15.dc1.easynews.com> |
| In reply to | #23940 |
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 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. 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). 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).
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-04-26 18:20 +0200 |
| Message-ID | <1606411.7n5RFCq9OI@PointedEars.de> |
| In reply to | #23958 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web