473,765 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\u 12428\u12390\u1 2356\u12414\u12 379');

It doesn't seem to work. Does anyone have an idea?
Jul 23 '05 #1
7 5745
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\u 12428\u12390\u1 2356\u12414\u12 379');

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.fromChar Code($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*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

"VK" <sc**********@y ahoo.com> wrote in message
news:41******** *************** @news.freenet.d e...
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.fromChar Code(). For example, excepting the fact
that antediluvian MSIE doesn't support all the Unicode characters (Moz FF
does), this works:

alert(String.fr omCharCode(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.'+Str ing.fromCharCod e(8221)+'\n'
+String.fromCha rCode(8195)+Str ing.fromCharCod e(8195)+' '
+String.fromCha rCode(8212)+' Benjamin Franklin,
1706'+String.fr omCharCode(8211 )+'1790');

This doesn't:

alert('\u8220Fo r 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.\u822 1\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.fromChar Code() for a language
that is all 16-bit characters.

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

alert('\u8220Fo r 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.fromChar Code($2);
}
);
document.write( s);
</script>
</div>
--
Rob
Jul 23 '05 #6
RobG <rg***@iinet.ne t.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.fromChar Code($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\u 12428\u12390\u1 2356\u12414\u12 379');

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.fromChar Code() 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
1994
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 display in Japanese? Thanks in advance.
8
10514
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 are translated by the browser, but not in the alert.
1
3167
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. I am quite new to xml and I am not sure how to deal with this situation. Is there a way to parse the jap characters ? or should the japanese characters be escaped in the xml file (i.e. Ӓ) for this to work.
2
3353
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 does System.out.println("$^%$%^^" ); //assume those are Japanese characters that are multibyte under EUC-JP The resulting output looks NOTHING like the characters I typed in. Apparently the character set being used to read the literal is...
3
1952
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 some strange reason, every once in a while the data changes to Japanese characters, it only happens once in a while, but once it happens that record is lost. i have tried everything compacting, importing to a new database, new table...What is...
2
3701
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 = myEsiCommand.ExecuteXmlReader(); reader.MoveToContent(); string myCSV = reader.ReadInnerXml(); //Load the xml fragment into the document XmlDocument xmlDataDoc = new XmlDocument();
11
4767
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 in japanese. But I am unable to display them back to GUI. It displays some junk characters Can anyone suggest me some way how to debug the issue. The code used for tranferring data from view to document is: " codec =...
2
4897
by: eros | last post by:
var xmlHttp; var m_placeholder; function executeProcess(serverscriptfile, placeholder, posts) { alert(posts); xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return;
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.