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? 12 2306 ko****@hotmail.com wrote: 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>
Thomas 'PointedEars' Lahn писал(а): ko****@hotmail.com wrote:
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>
----------
I've tested it and it worked OK for me. I just want to be sure that the
users will see correct text. I can rely on correct charset only.
Thanks for info. ko****@hotmail.com wrote: 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
Thomas 'PointedEars' Lahn писал(а): ko****@hotmail.com wrote:
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
--------------------
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. ko****@hotmail.com wrote: 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 <tt>Content-Type</tt> <a
href="http://en.wikipedia.org/wiki/HyperText_Transfer_Protocol"<acronym title="HyperText Transfer Protocol" HTTP</acronym></a> 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 header takes precedence.</p>
<p>Nevertheless, the <a
href="http://www.w3.org/TR/html4/charset.html#h-5.1"Document Character Set for <acronym
title="HyperText Markup Language">HTML</acronym> 4.01
documents</a> is still <a
href="http://en.wikipedia.org/wiki/Universal_Character_Set"<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']))
{
?>
<div><a href="?correct=1"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).
> ko****@hotmail.com wrote: 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 <tt>Content-Type</tt> <a href="http://en.wikipedia.org/wiki/HyperText_Transfer_Protocol" ><acronym title="HyperText Transfer Protocol" >HTTP</acronym></a> 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 header takes precedence.</p>
<p>Nevertheless, the <a href="http://www.w3.org/TR/html4/charset.html#h-5.1" >Document Character Set for <acronym title="HyperText Markup Language">HTML</acronym> 4.01 documents</a> is still <a href="http://en.wikipedia.org/wiki/Universal_Character_Set" ><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'])) { ?> <div><a href="?correct=1" >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> ko****@hotmail.com wrote: ko****@hotmail.com wrote: [...] > 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%3A%2F%2Fpointedears.de%2Fscripts%2Ftest% 2Fcyrillic2&submit=Submit&http=1.1&rawhtml=no&gzip =yes&type=GET&ua=Mozilla%2F5.0+%28X11%3B+U%3B+Linu x+i686%3B+en-US%3B+rv%3A1.8.0.1%29+Gecko%2F20060313+Debian%2F1. 5.dfsg%2B1.5.0.1-4+Firefox%2F1.5.0.1+Web-Sniffer%2F1.0.24>
(without ?correct=1, causing PHP to generate the wrong header value)
and
<URL:http://web-sniffer.net/?url=http%3A%2F%2Fpointedears.de%2Fscripts%2Ftest% 2Fcyrillic2%3Fcorrect%3D1&submit=Submit&http=1.1&r awhtml=no&gzip=yes&type=GET&ua=Mozilla%2F5.0+%28X1 1%3B+U%3B+Linux+i686%3B+en-US%3B+rv%3A1.8.0.1%29+Gecko%2F20060313+Debian%2F1. 5.dfsg%2B1.5.0.1-4+Firefox%2F1.5.0.1+Web-Sniffer%2F1.0.24>
(with ?correct=1, causing PHP to generate the correct header value)
[...] 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
> I thought the text to be self-explanatory, with that many links in it ... FWIW:
Compare the displayed response headers and document content with
http://web-sniffer.net/?url=http%3A%...iffer%2F1.0.24 (without ?correct=1, causing PHP to generate the wrong header value)
and
http://web-sniffer.net/?url=http%3A%...iffer%2F1.0.24 (with ?correct=1, causing PHP to generate the correct header value)
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
-----------------
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. ko****@hotmail.com wrote: > 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. [...] 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
Thomas 'PointedEars' Lahn wrote: ko****@hotmail.com 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
Thomas 'PointedEars' Lahn said the following on 4/4/2006 2:42 PM:
<snip> (Especially, signatures should not be quoted, unless there is an explicit reference in the followup.)
<snip>
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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joe Price |
last post by:
Hi chaps
I've got an XML file, within that file i've embedded html code using
the
<!]>
tag
I'm displaying that xml file through a browser using an xsl style
sheet. However it is displaying...
|
by: ryan baldwin |
last post by:
Hi, I posted this in the GotDotNet .NET Alerts forum, but that was 3 days
ago and still no reply so I'll try my luck here. My apologies if there's a
better group to post this question in, but at...
|
by: rhompi |
last post by:
Hi,
I have a problem displaying korean characters in javascript alerts.
Korean characters are displayed fine in menus, webpages, buttons,etc.
except in javascript alerts. Can anyone please help...
|
by: Luis Esteban Valencia |
last post by:
Is there a way to send timed alerts to ALL web clients conencted to the IIS
server (on a server level)?
IF NOT
Is there a way to send timed alerts to ALL web clients using a certain .Net
web...
|
by: swethasivaram |
last post by:
Hello
I have a Java-based web application whose interface can be in multiple
languages. My requirement is that the javascript alerts that I display
should be displayed in the language in which...
|
by: Andy Lim |
last post by:
Hi all,
In my recent project, my client uses Chinese Star software to type the
articles in chinese (using MS Word), and I need to display these articles
within ASP.NET pages. And, for this very...
|
by: anjachow |
last post by:
The system generated email that are automatically sent displaying well in any web-based mail systems (yahoo, msn, etc...). The foreign characters (vowels with accents and the ) aren't displaying...
|
by: =?Utf-8?B?R2VvcmdlIFIu?= |
last post by:
I used to get text message alerts from mobile.live saying I had a new Hotmail
e-mail. Now it says I reached my limit. I went in to My Alerts and checked
everything. It said it would reset. I double...
|
by: redpears007 |
last post by:
Hi Again,
Throwing this one out to you again as i am not getting anywhere and
can find little to no information out there.
I am currently displaying images (Jpegs) in access via the routine...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |