Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chinese Characters in JS File

Status
Not open for further replies.

irislauyk

Programmer
Nov 26, 2001
5
HK
Dear All,

My Web Page need to support displaying Dynamic Chinese Characters. So I use document.write() to print some Chinese that saved in the js file.

coding in JS File:
var stringTemp1 = "ÅwªïÂsÄý";

coding in HTML File
<html>
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=big5&quot;>
</head>

<body>
<script language=javascript>
var stringTemp2 = &quot;ÅwªïÂsÄý&quot;;

document.write(stringTemp1); <!-- rubbish -->
document.write(stringTemp2); <!-- chinese -->
</script>
</body>
</html>

However, these Chinese characters cannot be displayed in the English Win98 & IE 5, which other Chinese that stored in the HTML can be displayed successfully. ( charset=big5 )

if I stored all the chinese words in the html, and use the document.write to print them. they can display also.

But there are around 50 files pointing to them, I don't want to modify each file when there are some changes.

So is there any workaround???

Thanks
 
I have win2000 now but before I had win 98 and could not type Japanese (double encoded characters) in notepad (only in IE with IME).

You can escape your string value and when it is displayed unescape it.
An example of this is below:


<input type=button value=&quot;show unescaped double encoded string&quot; onclick=&quot;alert(unescape('%u6625'));&quot;><br>
source:<br>
<textarea id=txtsrc></textarea>
<input type=button onclick=&quot;makedes();&quot; value=&quot;set destination value&quot;><br>
destination:<br>
<textarea id=txtdes></textarea>
<input type=button onclick=&quot;makesrc();&quot; value=&quot;set source value&quot;><br>
<script>
function makedes() {
document.getElementById(&quot;txtdes&quot;).value=escape(document.getElementById(&quot;txtsrc&quot;).value);
}
function makesrc() {
document.getElementById(&quot;txtsrc&quot;).value=unescape(document.getElementById(&quot;txtdes&quot;).value);
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top