will the alerts displaying correctly?

K

korund

How to make javascript alert with non-english text displaying correctly
on computers where english only is default system & language settings?
For web page the solution is just use meta tags:
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1251">
Will this work for javascript alerts also?
 
T

Thomas 'PointedEars' Lahn

How to make javascript alert with non-english text displaying correctly
on computers where english only is default system & language settings?
For web page the solution is just use meta tags:
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1251">
Will this work for javascript alerts also?

Maybe, maybe not. Windows-1251 ("Cyrillic") certainly includes characters
that are not part of the English language.[1] (The system and user
interface language do not matter.) But you SHOULD always send the correct
Content-Type HTTP header to declare the correct resource encoding (which
takes precedence over any meta[http-equiv]) to encode the used characters
of the HTML Document Character Set (UCS), and include meta[http-equiv] for
local use only.[2]

If that encoding does not allow to encode the character as-is, you can
either use character references (CRs) or character entity references (CERs)
_in the markup_, such as `Й', or change the encoding of the resource
content itself (and declare the new encoding instead). It is a common
misconception that the encoding of a markup resource would restrict you
to a certain character set. That is not the case; HTML 4.01 and XML
documents will use UCS as Document Character Set always.[3][4]

Note that CRs and CERs are not evaluated within JS strings, unless the piece
of JS code is CDATA _attribute_ content (or PCDATA _element_ content, what
you usually do not want).


PointedEars
___________
[1] <URL:http://en.wikipedia.org/wiki/Windows-1251>

[2] <URL:http://rfc-editor.org/rfc/rfc1945.txt>, 10.5
<URL:http://rfc-editor.org/rfc/rfc1945.txt>, 14.17

[3] <URL:http://www.w3.org/TR/html4/charset.html#doc-char-set>
<URL:http://www.w3.org/TR/html4/sgml/sgmldecl.html>

<URL:http://www.w3.org/TR/REC-xml/#charsets>
<URL:http://www.w3.org/TR/xml11#charsets>
<URL:http://www.w3.org/TR/NOTE-sgml-xml-971215.html#null3>

[4] Interestingly, HTML 3.2 documents use only ISO 646 (IA5) instead:
<URL:http://www.w3.org/TR/REC-html32#sgmldecl>
 
K

korund

Thomas 'PointedEars' Lahn пиÑал(а):
How to make javascript alert with non-english text displaying correctly
on computers where english only is default system & language settings?
For web page the solution is just use meta tags:
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1251">
Will this work for javascript alerts also?

Maybe, maybe not. Windows-1251 ("Cyrillic") certainly includes characters
that are not part of the English language.[1] (The system and user
interface language do not matter.) But you SHOULD always send the correct
Content-Type HTTP header to declare the correct resource encoding (which
takes precedence over any meta[http-equiv]) to encode the used characters
of the HTML Document Character Set (UCS), and include meta[http-equiv] for
local use only.[2]

If that encoding does not allow to encode the character as-is, you can
either use character references (CRs) or character entity references (CERs)
_in the markup_, such as `Й', or change the encoding of the resource
content itself (and declare the new encoding instead). It is a common
misconception that the encoding of a markup resource would restrict you
to a certain character set. That is not the case; HTML 4.01 and XML
documents will use UCS as Document Character Set always.[3][4]

Note that CRs and CERs are not evaluated within JS strings, unless the piece
of JS code is CDATA _attribute_ content (or PCDATA _element_ content, what
you usually do not want).


PointedEars
___________
[1] <URL:http://en.wikipedia.org/wiki/Windows-1251>

[2] <URL:http://rfc-editor.org/rfc/rfc1945.txt>, 10.5
<URL:http://rfc-editor.org/rfc/rfc1945.txt>, 14.17

[3] <URL:http://www.w3.org/TR/html4/charset.html#doc-char-set>
<URL:http://www.w3.org/TR/html4/sgml/sgmldecl.html>

<URL:http://www.w3.org/TR/REC-xml/#charsets>
<URL:http://www.w3.org/TR/xml11#charsets>
<URL:http://www.w3.org/TR/NOTE-sgml-xml-971215.html#null3>

[4] Interestingly, HTML 3.2 documents use only ISO 646 (IA5) instead:
<URL:http://www.w3.org/TR/REC-html32#sgmldecl>
 
T

Thomas 'PointedEars' Lahn

I've tested it and it worked OK for me.

That does not matter.
I just want to be sure that the users will see correct text.

They will see the correct text if the declared encoding and the actual
encoding of the resource match. The encoding declared in the HTTP header,
not in the `meta' element.
I can rely on correct charset only. Thanks for info.
^^^^^^^^^^^^^^^
You are welcome, but ISTM you have not understood yet.

Please trim your quotes next time.
<URL:http://www.safalra.com/special/googlegroupsreply/>


PointedEars
 
K

korund

Thomas 'PointedEars' Lahn пиÑал(а):
That does not matter.


They will see the correct text if the declared encoding and the actual
encoding of the resource match. The encoding declared in the HTTP header,
not in the `meta' element.

^^^^^^^^^^^^^^^
You are welcome, but ISTM you have not understood yet.

Please trim your quotes next time.
<URL:http://www.safalra.com/special/googlegroupsreply/>


PointedEars --------------------

They will see the correct text if the declared encoding and the actual
encoding of the resource match. The encoding declared in the HTTP header,
not in the `meta' element.

not clear. How should look this 'right' encoding in html page? Its
better to show example with 'right' HTTP header and 'meta' element.
 
T

Thomas 'PointedEars' Lahn

Thomas 'PointedEars' Lahn пиÑал(а):
[...]
I can rely on correct charset only. Thanks for info.
^^^^^^^^^^^^^^^
You are welcome, but ISTM you have not understood yet.

Please trim your quotes next time.
<URL:http://www.safalra.com/special/googlegroupsreply/>
[...]
They will see the correct text if the declared encoding and the actual
encoding of the resource match. The encoding declared in the HTTP
header, not in the `meta' element.

not clear. How should look this 'right' encoding in html page?

It is the encoding used when storing the text content as a file.
Its better to show example with 'right' HTTP header and 'meta' element.

Try <URL:http://pointedears.de/scripts/test/cyrillic2>
(It has been a while since I have learned Russian, so please bear with me.)

This is the source code used:

<?php
if (isset($_GET['correct']))
{
header('Content-Type: text/html; charset=UTF-8');
}

// Demonstrates what the wrong default encoding can do to a resource
else
{
header('Content-Type: text/html; charset=Windows-1251');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scripting Test Case: Encoding vs. Document Character Set</title>

<meta name="DCTERMS.created" content="2006-04-04">

<script type="text/javascript">
function foo()
{
alert("Понимаешь?");
}
</script>

<style type="text/css">
body {
background-color: white;
color: black;
}

div, p {
margin: 1em auto;
}

acronym {
border-bottom:1px dotted #999;
cursor: help;
}
</style>
</head>

<body>
<?php
if (!isset($_GET['correct']))
{
?>
<p>This <a href="http://en.wikipedia.org/wiki/UTF-8"><acronym
title="8-bit Unicode Transformation Format">UTF-8</acronym></a>
encoded resource is served with the wrong encoding declaration in
the said:
<acronym title="HyperText Transfer Protocol"
HTTP</acronym></a>&nbsp;header (<tt>charset=<a href="http://en.wikipedia.org/wiki/Windows-1251"
Windows-1251</a></tt>). That the included <a href="http://www.w3.org/TR/html4/struct/global.html#edef-META"
<tt>meta</tt></a> element "declares" the correct encoding does
not matter; the HTTP&nbsp;header takes precedence.</p>

Document Character Set for <acronym
title="HyperText Markup Language">HTML</acronym>&nbsp;4.01
documents said:
<acronym title="the Universal Character Set">UCS</acronym></a>,
so character references can be used in <a
href="http://en.wikipedia.org/wiki/CDATA"><tt>CDATA</tt></a>
attribute values to represent non-<a
href="http://en.wikipedia.org/wiki/ASCII"><acronym
title="American Standard Code for Information Interchange"
ASCII</acronym></a> characters:</p>
<?php
}
?>

<div><input type="button"
value="Выбери
меня!"
lang="ru"
onclick="foo();"></div>

<?php
if (!isset($_GET['correct']))
{
?>
Serve (almost) the same content with the correct encoding
declaration
(<tt>charset=UTF-8</tt>)</a></div>
<?php
}
?>
</body>
</html>


HTH

PointedEars

P.S.
I asked you to trim your quotes already (reduce it to the minimum necessary
to retain context, as you can observe in [my] other postings).
 
K

korund

Thomas 'PointedEars' Lahn пиÑал(а):
[...]
I can rely on correct charset only. Thanks for info.
^^^^^^^^^^^^^^^
You are welcome, but ISTM you have not understood yet.

Please trim your quotes next time. http://www.safalra.com/special/googlegroupsreply/>
[...]
They will see the correct text if the declared encoding and the actual
encoding of the resource match. The encoding declared in the HTTP
header, not in the `meta' element.

not clear. How should look this 'right' encoding in html page?

It is the encoding used when storing the text content as a file.
Its better to show example with 'right' HTTP header and 'meta' element.

Try <URL:http://pointedears.de/scripts/test/cyrillic2>
(It has been a while since I have learned Russian, so please bear with me..)

This is the source code used:

<?php
if (isset($_GET['correct']))
{
header('Content-Type: text/html; charset=UTF-8');
}

// Demonstrates what the wrong default encoding can do to a resource
else
{
header('Content-Type: text/html; charset=Windows-1251');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scripting Test Case: Encoding vs. Document Character Set</title>

<meta name="DCTERMS.created" content="2006-04-04">

<script type="text/javascript">
function foo()
{
alert("Понимаешь?");
}
</script>

<style type="text/css">
body {
background-color: white;
color: black;
}

div, p {
margin: 1em auto;
}

acronym {
border-bottom:1px dotted #999;
cursor: help;
}
</style>
</head>

<body>
<?php
if (!isset($_GET['correct']))
{
?>
<p>This <a href="http://en.wikipedia.org/wiki/UTF-8"><acronym
title="8-bit Unicode Transformation Format">UTF-8</acronym></a>
encoded resource is served with the wrong encoding declaration in
the said:
<acronym title="HyperText Transfer Protocol"
HTTP</acronym></a>&nbsp;header (<tt>charset=<a href="http://en.wikipedia.org/wiki/Windows-1251"
Windows-1251</a></tt>). That the included <a href="http://www.w3.org/TR/html4/struct/global.html#edef-META"
<tt>meta</tt></a> element "declares" the correct encoding does
not matter; the HTTP&nbsp;header takes precedence.</p>

Document Character Set for <acronym
title="HyperText Markup Language">HTML</acronym>&nbsp;4.01
documents said:
<acronym title="the Universal Character Set">UCS</acronym></a>,
so character references can be used in <a
href="http://en.wikipedia.org/wiki/CDATA"><tt>CDATA</tt></a>
attribute values to represent non-<a
href="http://en.wikipedia.org/wiki/ASCII"><acronym
title="American Standard Code for Information Interchange"
ASCII</acronym></a> characters:</p>
<?php
}
?>

<div><input type="button"
value="Выбери
меня!"
lang="ru"
onclick="foo();"></div>

<?php
if (!isset($_GET['correct']))
{
?>
Serve (almost) the same content with the correct encoding
declaration
(<tt>charset=UTF-8</tt>)</a></div>
<?php
}
?>
</body>
</html>


HTH

PointedEars

P.S.
I asked you to trim your quotes already (reduce it to the minimum necessary
to retain context, as you can observe in [my] other postings).
----------------------

this one show wrong text:

http://pointedears.de/scripts/test/cyrillic2 show wrong text,
this -correct:
http://pointedears.de/scripts/test/cyrillic2?correct=1

but both pages have same doctype & meta tags, I dont understand what is
difference:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scripting Test Case: Encoding vs. Document Character
Set</title>

<meta name="DCTERMS.created" content="2006-04-04">

AND

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scripting Test Case: Encoding vs. Document Character
Set</title>

<meta name="DCTERMS.created" content="2006-04-04">


Button value in both pages shown unreadable:

<div><input type="button"
value="Выбери
меня!"
lang="ru"
onclick="foo();"></div>
 
T

Thomas 'PointedEars' Lahn

Thomas 'PointedEars' Lahn пиÑал(а):
[...]
P.S.
I asked you to trim your quotes already (reduce it to the minimum
necessary to retain context, as you can observe in [my] other postings).
----------------------

this one show wrong text:

http://pointedears.de/scripts/test/cyrillic2 show wrong text,

this -correct:
http://pointedears.de/scripts/test/cyrillic2?correct=1

Works as designed :)
but both pages have same doctype & meta tags,

As I said (and wrote), the `meta' element does not matter really.
I dont understand what is difference:

I thought the text to be self-explanatory, with that many links in it ...
FWIW:

Compare the displayed response headers and document content with

<URL:http://web-sniffer.net/?url=http://...+1.5.0.1-4+Firefox/1.5.0.1+Web-Sniffer/1.0.24>
(without ?correct=1, causing PHP to generate the wrong header value)

and

[...]
Button value in both pages shown unreadable:

The button value (its caption) should show the _same_ (cyrillic) letters
with both declarations, or either your browser is broken or you do not have
the correct Unicode font installed (or configured). However, the alert()
message box displayed when the button is clicked should be _different_ (and
you wrote that it was), or your browser is broken.

Next time you do not trim your quotes as recommended, I will stop reading
your postings. I have given you enough hints now.


PointedEars
 
K

korund

I thought the text to be self-explanatory, with that many links in it ...
Compare the displayed response headers and document content with
http://web-sniffer.net/?url=http://...+1.5.0.1-4+Firefox/1.5.0.1+Web-Sniffer/1.0.24
(without ?correct=1, causing PHP to generate the wrong header value)

http://web-sniffer.net/?url=http://...+1.5.0.1-4+Firefox/1.5.0.1+Web-Sniffer/1.0.24
(with ?correct=1, causing PHP to generate the correct header value)
The button value (its caption) should show the _same_ (cyrillic) letters
with both declarations, or either your browser is broken or you do not have
the correct Unicode font installed (or configured). However, the alert()
message box displayed when the button is clicked should be _different_ (and
you wrote that it was), or your browser is broken.
Next time you do not trim your quotes as recommended, I will stop reading
your postings. I have given you enough hints now.
PointedEars
-----------------
this Google Groups has extremelly inconvenient plain user interface so
I really problematic trim someting there
Your examples imply the use of php, while I meant using just plain html
pages. And button value is broken for me in both cases. Dont know what
about browser, i still use MSIE, though its bad, however
As to correct Unicode font installed -i have default configuratuon,
usually no problem to read anything.
 
T

Thomas 'PointedEars' Lahn

The button value (its caption) should show the _same_ (cyrillic) letters
with both declarations, or either your browser is broken or you do not
have the correct Unicode font installed (or configured). However, the
alert() message box displayed when the button is clicked should be
_different_ (and you wrote that it was), or your browser is broken.
Next time you do not trim your quotes as recommended, I will stop reading
your postings. I have given you enough hints now.
[...]
this Google Groups has extremelly inconvenient [...] user interface

True. Use Google Groups only for research, not for posting.
so I really problematic trim someting there

No, it is not :)

<URL:http://www.safalra.com/special/googlegroupsreply/>
<URL:http://netmeister.org/news/learn2quote.html>
<URL:http://jibbering.com/faq/faq_notes/pots1.html>

(Especially, signatures should not be quoted, unless there is an explicit
reference in the followup.)
Your examples imply the use of php, while I meant using just plain html
pages.

PHP was only used to simulate the server sending a default encoding that
does not match the actual encoding of the resource. What happens is
that the `meta' element is ignored then, which is correct behavior.[1]
Therefore, the UTF-8 encoded Cyrillic characters look garbled then.

[1] Another example:
<URL:http://issues.apache.org/bugzilla/show_bug.cgi?id=23421>
(The reporter's name is "Martin Dürst", stored UTF-8 encoded;
the document contains meta[content="text/html; charset=UTF-8"],
but is incorrectly served as charset=ISO-8859-1 in the
Content-Type HTTP header.)
And button value is broken for me in both cases. Dont know what
about browser, i still use MSIE, though its bad, however

Define: broken. (URL for screenshot?)
As to correct Unicode font installed -i have default configuratuon,
usually no problem to read anything.

Straynge. [psf 4.15]


PointedEars
 
T

Thomas 'PointedEars' Lahn

Thomas said:
(e-mail address removed) wrote:
[...]
[1] Another example:
<URL:http://issues.apache.org/bugzilla/show_bug.cgi?id=23421>
(The reporter's name is "Martin Dürst", stored UTF-8 encoded;
the document contains meta[content="text/html; charset=UTF-8"],

Hm, it does not contain a `meta' element. Maybe that makes the
difference for your IE. That would be against the HTTP standard,
so nothing that should be relied upon, though.
but is incorrectly served as charset=ISO-8859-1 in the
Content-Type HTTP header.)
And button value is broken for me in both cases. Dont know what
about browser, i still use MSIE, though its bad, however
[...]


PointedEars
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 4/4/2006 2:42 PM:

(Especially, signatures should not be quoted, unless there is an explicit
reference in the followup.)

Straynge. [psf 4.15]


PointedEars

Where is the "signature" that should not be quoted? If you want to
continue to rant about people quoting a "signature" that is *NOT* a
signature, then start using a proper signature. Otherwise, shut up with
your pedantic ramblings about such things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top