473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Japanese characters in alert

I`m trying to show japanese characters in an alert, like;

alert('実装されていませ');

This doesn't work as shown in this post:
http://groups.google.com/groups?hl=e...com%26rnum%3D2

This post implyes that it's possible to use the \uXXXX notation
instead. But is this notation using the same codes? Can I transform
this
alert('実装されていませ');

into this?
alert('\u23455\u35013\u12373\u12428\u12390\u12356\ u12414\u12379');

It doesn't seem to work. Does anyone have an idea?
Jul 23 '05 #1
7 5717
VK
You have to use hex values, not decimal ones:
\uFFFF
Jul 23 '05 #2
Daniel wrote:
I`m trying to show japanese characters in an alert, like;

alert('実装されていませ');

This doesn't work as shown in this post:
http://groups.google.com/groups?hl=e...com%26rnum%3D2
This post implyes that it's possible to use the \uXXXX notation
instead. But is this notation using the same codes? Can I transform
this
alert('実装されていませ');

into this?
alert('\u23455\u35013\u12373\u12428\u12390\u12356\ u12414\u12379');

It doesn't seem to work. Does anyone have an idea?


<script type="text/javascript">
var s = '実装されていませ';
// s = 'ABC';
s = s.replace(
/&#(\d+);/g,
function($1, $2) {
return String.fromCharCode($2);
}
);

alert(s);
</script>

You want to turn the string of character entities into a string of actual characters based on those character entity values, which is what the code above does. It generates the string as requested (which can be confirmed by uncommenting the second assignment to
-s-), but I don't know if it actually works or not, I don't have Japanese language support installed.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

"VK" <sc**********@yahoo.com> wrote in message
news:41***********************@news.freenet.de...
You have to use hex values, not decimal ones:
\uFFFF


That only seems to work for 8-bit characters. It seems that 16-bit
characters require String.fromCharCode(). For example, excepting the fact
that antediluvian MSIE doesn't support all the Unicode characters (Moz FF
does), this works:

alert(String.fromCharCode(8220)+'For having lived long, I have experienced
many instances\n'
+'of being obliged, by better information or fuller consideration,\n'
+'to change opinions, even on important subjects, which\n'
+'I once thought right but found to be
otherwise.'+String.fromCharCode(8221)+'\n'
+String.fromCharCode(8195)+String.fromCharCode(819 5)+' '
+String.fromCharCode(8212)+' Benjamin Franklin,
1706'+String.fromCharCode(8211)+'1790');

This doesn't:

alert('\u8220For having lived long, I have experienced many instances\n'
+'of being obliged, by better information or fuller consideration,\n'
+'to change opinions, even on important subjects, which\n'
+'I once thought right but found to be otherwise.\u8221\n'
+'\u8195\u8195 \u8212 Benjamin Franklin, 1706\u82111790');

(For the typographically-unperceptive: the above contains left/right double
quotes, em spaces, an em dash, and an en dash)

There must be a better way than using String.fromCharCode() for a language
that is all 16-bit characters.

nf
Jul 23 '05 #4
I wrote:
This doesn't:

alert('\u8220For having lived long, I have experienced many instances\n'


Oops, sorry. I didn't convert decimal numbers to hex. Actually works fine
when done right.

Jul 23 '05 #5
Grant Wagner wrote:
[...]
You want to turn the string of character entities into a string of actual characters based on those character entity values, which is what the code above does. It generates the string as requested (which can be confirmed by uncommenting the second assignment to
-s-), but I don't know if it actually works or not, I don't have Japanese language support installed.


FWIW, I added Japanese language support & rebooted - some characters
appeared that could well be Japanese. It 'worked' in IE and Firefox.
However, I have no idea what you have written or whether the correct
characters appeared.

<div style="border: 1px solid red; width: 30em; text-align: center;">
<script type="text/javascript">
var s =
'実装されていませ';
s = s.replace(
/&#(\d+);/g,
function($1, $2) {
return String.fromCharCode($2);
}
);
document.write(s);
</script>
</div>
--
Rob
Jul 23 '05 #6
RobG <rg***@iinet.net.auau> wrote in message news:<XH*****************@news.optus.net.au>...
Grant Wagner wrote:
[...]
You want to turn the string of character entities into a string of actual characters based on those character entity values, which is what the code above does. It generates the string as requested (which can be confirmed by uncommenting the second assignment to
-s-), but I don't know if it actually works or not, I don't have Japanese language support installed.


FWIW, I added Japanese language support & rebooted - some characters
appeared that could well be Japanese. It 'worked' in IE and Firefox.
However, I have no idea what you have written or whether the correct
characters appeared.

<div style="border: 1px solid red; width: 30em; text-align: center;">
<script type="text/javascript">
var s =
'実装されていませ';
s = s.replace(
/&#(\d+);/g,
function($1, $2) {
return String.fromCharCode($2);
}
);
document.write(s);
</script>
</div>

Hi Rob and everyone else!

Thanks a bunch for your answers. I haven't installed japanese
characters. So it doesn't work in ie, but in firefox - like a dream!
/Daniel
Jul 23 '05 #7
Daniel wrote:
Can I transform this
alert('実装されていませ');

into this?
alert('\u23455\u35013\u12373\u12428\u12390\u12356\ u12414\u12379');

It doesn't seem to work. Does anyone have an idea?


"&#" in SGML must be followed by the decimal code point representation,
"\u" in ECMAScript compliant implementations by the hexadecimal code point
representation (like "&#x...." in SGML). 23455 != 0x23455 = 144469.

Although String.fromCharCode() does that conversion in a way, it is
unnecessary and therefore inefficient here. Do the conversion yourself
once instead and type the appropriate code point representation. You
should test if Unicode literals are supported by an implementation with
testing the length of the literal "\u0815" (you may use any four-digit
hexadecimal number here); if it is larger than 1, Unicode literals are
not supported by the implementation, thus you cannot provide message
boxes in the respective language.
PointedEars
--
Stay the patient course. Of little worth is your ire. The network is down.
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Shelly | last post by:
Hi I am developing a web application for multi language support. But when I view in browser, all languages are shown except Japanese. Do I need to follow some conventions or special settings for...
8
by: Daniel | last post by:
I'm trying to make a site work for japanese characters. It works fine except for the alerts in javascript. The characters are stored in unicode, as this; 'コミック全巻配' Those unicode characters...
1
by: Sriv Chakravarthy | last post by:
I am trying to use xerces-c SAX parser to parse japanese characters. I have a <?xml... utf-8> line in the xml file. When the parser encounters the jap characters it throws a UTFDataFormatException....
2
by: Robert M. Gary | last post by:
I'm using JRE 1.5 on Solaris Japanese (Sparc). The JVM claims its default character set is EUC-JP I'm seeing two strange things when using Japanese character sets... 1) If I write a program that...
3
by: Mitchell Thomas | last post by:
I recently created a new database in Access 2002. I took data from an access 97 database converted one of the tables to access 2002 and then imported it into a new table in access 2002. but for...
2
by: Joseph | last post by:
Hello. I have this problem. See I have a transformed XML file and I checked its contents prior to outputting it to excel file via responseset. here is the gist of the code: XmlReader reader =...
11
by: prats | last post by:
I want to write a GUI application in PYTHON using QT. This application is supposed to take in Japanese characters. I am using PyQt as the wrapper for using QT from python. I am able to take input...
2
by: eros | last post by:
var xmlHttp; var m_placeholder; function executeProcess(serverscriptfile, placeholder, posts) { alert(posts); xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert...
0
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$) { } ...
0
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...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.