hebrew with javascript

all i want is to alert hebrew words...
when i save the hebrew text on my server http manager it being saved like
יברית
when i save it in ftp it looks like òçéòëç

the thing is that all my html's saved like this and when i set
<meta http-equiv="content-type" Content="text/html;charset=utf-8">
it being printed good...

but alerts print this babmo jambo...
how can i set right?

10q
<script>
function changeIt() {
 alert('englisòçéòëçh_&#1506;&#1497;&#1489;&#1512;&#1497;&#1514;');
}
 
setTimeout('changeIt()',900);
</script>

Open in new window

sasha85Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nizsmoDeveloperCommented:
Try annd use the unescape function:

alert(unescape("&#1506;&#1497;&#1489;&#1512;&#1497;&#1514;"));
0
Sinoj SebastianCTO & OpenERP Project managerCommented:
I think you have to do it like this
alert('englisòçéòëçh_\u1506\u1497\u1489\u1512\u1497\u1514;');
0
Sinoj SebastianCTO & OpenERP Project managerCommented:
You see, This is working in my FF 2 Ubuntu
alert(<div>englisòçéòëçh_&#1506;&#1497;&#1489;&#1512;&#1497;&#1514;</div>)
please test it on other browsers
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

sasha85Author Commented:
sinoj, i do not understadn what you mean...?
0
sasha85Author Commented:
0
Sinoj SebastianCTO & OpenERP Project managerCommented:
I am on an Ubuntu Machine
When I use
alert(<div>englisòçéòëçh_&#1506;&#1497;&#1489;&#1512;&#1497;&#1514;</div>)
My firefox 2 give me this result "http://i18.tinypic.com/6lkkuok.png" that I thought what you want.

I do not have a windows machine now to test it on IE.
0
sasha85Author Commented:
no man...this is not what i want:)

<div id="test">
&#1490;&#1499;&#1490;&#1490;&#1499;&#1499;&#1490;
</div>
 
<script>
alert(document.getElementById('test').innerHTML)
</script>
http://ilmc.brinkster.net/comersus/crm/hebalerts2.htm

this for example do work...but i am searching a shorter solution...
0
Sinoj SebastianCTO & OpenERP Project managerCommented:
Yes, that is what I mean "HTML inside alert"
Hope you will get a better solution. :)
0
sasha85Author Commented:
do you know shorter way to write it? without div?
0
Sinoj SebastianCTO & OpenERP Project managerCommented:
You can shorthand

<div id="test">
&#1490;&#1499;&#1490;&#1490;&#1499;&#1499;&#1490;
</div>
<script>
alert(document.getElementById('test').innerHTML)
</script>

To
alert(<div>&#1490;&#1499;&#1490;&#1490;&#1499;&#1499;&#1490;</div>)

it is not a simple string. so, no quotes.( I've seen that you are trying it with quotes)
If you are not satisfied with the solution, wait some more time. Someone else may come up with better solution.

:)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sasha85Author Commented:
alert(<div>&#1490;&#1499;&#1490;&#1490;&#1499;&#1499;&#1490;</div>)
sorry but this not realy works...
0
ZylochCommented:
Oh, Javascript alert does not handle character entities. Instead, use Unicode:

alert("\u1490\u1499\u1490");
0
sasha85Author Commented:
i cannot use this alert("\u1490\u1499\u1490");
cause i not realy type those letters...its the server that translate my hebrew into those codes...and ofcourse i am not going to sit and put \u before every code
0
ZylochCommented:
Try using a replacement. See the sample code:

<html>
<head>
<title>EE Question 22994890</title>
<script type="text/javascript">

function fn(num) {
      return parseInt(num);
}

var entity_str = "&#1490;&#1499;&#1490;&#1490;&#1499;&#1499;&#1490;";
var escaped_str = entity_str.replace(/&#(\d{4});/g, function(entity, digits) {
      var d = parseInt(digits).toString(16);
      for (var i = 0; i < 4 - d.length; i++) {
            d = 0 + d;
      }
      return "%u" + d;
})
var unicode_str = unescape(escaped_str);
alert(unicode_str);

</script>
</head>
<body>
</body>
</html>
0
nizsmoDeveloperCommented:
sasha85,

I managed to get this going, and quite simple too.
Credits to Zyloch.
<script>
var str = "&#1506;&#1490;&#1489;&#1512;&#1497;&#1514;";
var newstr = str.replace(/\&#/g,"\%u").replace(/;/g,"");
alert(unescape(newstr));
</script>

Open in new window

0
ZvonkoSystems architectCommented:
What do you get when you convert your Ivrit cource on server side by htmlentities():
http://www.php.net/manual/en/function.htmlentities.php
<script>
function changeIt() {
 alert('englis: <?php = htmlentities($yourIvritString) ?> ');
}
 
setTimeout('changeIt()',900);
</script>

Open in new window

0
ZvonkoSystems architectCommented:
By the way, I see Ivrit diferently speled in alephbet here: http://milon.morfix.co.il/Default.aspx

â´Ñ°è´Ùê

éÁ¸ÜÕ¹Ý
ְеÑ
0
ZvonkoSystems architectCommented:
Second test:

â´Ñ°è´Ùê
 
éÁ¸ÜÕ¹Ý
ְеÑ

Open in new window

0
ZvonkoSystems architectCommented:
OK, EE character conversion was changed...
0
sasha85Author Commented:
sorry , i tried those codes and nothing work right...
0
nizsmoDeveloperCommented:
sasha85,

did you try my code? seems to work when i tried it..
0
sasha85Author Commented:
<script>
var str = "&#1506;&#1490;&#1489;&#1512;&#1497;&#1514;";
var newstr = str.replace(/\&#/g,"\%u").replace(/;/g,"");
alert(unescape(newstr));
</script>

yes i got ???????
0
nizsmoDeveloperCommented:
do you have the correct fonts installed? I presumed I got ????? because I do not have the fonts installed.
0
sasha85Author Commented:
yap...i got all hebrew font installed here...i do not know how to read all of it "yet" but i will learn:)
????? sure thing that it is not hebrew:0
0
nizsmoDeveloperCommented:
I assumed that ???? represented the hebrew characters which would not display correctly on my machine without correct font, but hmmm not sure why it is not working for you either..
0
Sinoj SebastianCTO & OpenERP Project managerCommented:
Now the only solution that I can think of

<script>
      var temp = document.createElement('div')
      temp.innerHTML= "&#1506;&#1490;&#1489;&#1512;&#1497;&#1514;";
      alert(temp.innerHTML);
</script>

0
ZvonkoSystems architectCommented:
So you say my proposal with <?php = htmlentities($yourIvritString) ?> did not work for Hebrew?
Can you confirm that?

0
sasha85Author Commented:
the prob that i never used php...and i got no palce to run it yet...but i am attend to install php server soon...
but for this need php is not good cause i run it on asp
0
ZvonkoSystems architectCommented:
Ah! OK, then you need a solution in VBScript for your ASP page, right?
0
sasha85Author Commented:
nope...i am using pure asp...no vb...it is running on asp server
0
ZvonkoSystems architectCommented:
ASP you can script in JScript or VBScript.
What do you prefer?
0
sasha85Author Commented:
never used jscript...i prefer vbs...but i see that any solution will be syntax longer than the one i wrote...
0
ZvonkoSystems architectCommented:
I would create a VBScript function that returns \u encoded characters from an Ivrit string, but when you do not need then I do not waste my time...
0
sasha85Author Commented:
no no...zvonko...don;t do this...i will use my div rather...it is much shorter...thanks man
0
ZvonkoSystems architectCommented:
ok, no problem.
If you need no more support in this thread then please close this question, either by choosing the comment that helped you or by asking Community Support to close this question by posting a question close request here: http:/Community_Support/General/newQuestionWizard.jsp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.