We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

UTF8 with alert of Javascript

ndhai
ndhai asked
on
Medium Priority
634 Views
Last Modified: 2008-02-01
Hello

I get some value "Russia" from my file RessourceBundle
and I have a UTF8 string following

<script language='javascript'>
var MSG_INVALID = "&#1042;&#1099; &#1074;&#1074;&#1077;&#1083;&#1080; &#1085;&#1077;&#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1100;&#1085;&#1099;&#1077; &#1089;&#1080;&#1084;&#1074;&#1086;&#1083;&#1099; &#1074; %0.\n&#1042;&#1074;&#1077;&#1076;&#1080;&#1090;&#1077; &#1076;&#1088;&#1091;&#1075;&#1080;&#1077; &#1089;&#1080;&#1084;&#1074;&#1086;&#1083;&#1099;"
</script>

when I alert : alert(MSG_INVALID), it don't display like unicode
I know we can use
  alert(String.fromCharCode(1042,1099,1074,1074, ......));
or we can use the hidden input of form to stock this value
but I dont know there are another solutions for this?

thanks a lot
best regards
Comment
Watch Question

Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
Or a hidden div, which is what I would use if no-one has a good solution

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>Untitled</title>
<script>
function alertIt(replacement) {
  var x = document.getElementById('rusmsg').innerHTML;
  x=x.replace('%0',replacement).replace('\\n','\n')
  alert(x)
}  
</script>
</head>

<body onLoad="alertIt('Error 3')">
<div id ="rusmsg" style="display:none">&#1042;&#1099; &#1074;&#1074;&#1077;&#1083;&#1080; &#1085;&#1077;&#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1100;&#1085;&#1099;&#1077; &#1089;&#1080;&#1084;&#1074;&#1086;&#1083;&#1099; &#1074; %0.\n&#1042;&#1074;&#1077;&#1076;&#1080;&#1090;&#1077; &#1076;&#1088;&#1091;&#1075;&#1080;&#1077; &#1089;&#1080;&#1084;&#1074;&#1086;&#1083;&#1099;</div>


</body>
</html>

Author

Commented:
thanks for your reponse but it likes my method
i think we haven't no choice with String.fromCharCode
admin, could you close this question ?
thanks
ndhai
Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
Please ask here http://www.experts-exchange.com/Community_Support/ for a paq/refund
Commented:
Closed, 80 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.