Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

hebrew with javascript

Posted on 2007-12-01
35
Medium Priority
?
511 Views
Last Modified: 2008-02-01
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

0
Comment
Question by:sasha85
  • 13
  • 9
  • 6
  • +2
35 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20387399
Try annd use the unescape function:

alert(unescape("&#1506;&#1497;&#1489;&#1512;&#1497;&#1514;"));
0
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 20387410
I think you have to do it like this
alert('englisòçéòëçh_\u1506\u1497\u1489\u1512\u1497\u1514;');
0
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 20387427
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sasha85
ID: 20387562
sinoj, i do not understadn what you mean...?
0
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 20387583
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
 

Author Comment

by:sasha85
ID: 20387600
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
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 20387622
Yes, that is what I mean "HTML inside alert"
Hope you will get a better solution. :)
0
 

Author Comment

by:sasha85
ID: 20387638
do you know shorter way to write it? without div?
0
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 400 total points
ID: 20387654
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
 

Author Comment

by:sasha85
ID: 20387732
alert(<div>&#1490;&#1499;&#1490;&#1490;&#1499;&#1499;&#1490;</div>)
sorry but this not realy works...
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 20387752
Oh, Javascript alert does not handle character entities. Instead, use Unicode:

alert("\u1490\u1499\u1490");
0
 

Author Comment

by:sasha85
ID: 20388784
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
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 400 total points
ID: 20389488
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
 
LVL 21

Assisted Solution

by:nizsmo
nizsmo earned 400 total points
ID: 20389590
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
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 800 total points
ID: 20390711
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 20390726
By the way, I see Ivrit diferently speled in alephbet here: http://milon.morfix.co.il/Default.aspx

â´Ñ°è´Ùê

éÁ¸ÜÕ¹Ý
ְеÑ
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 20390730
Second test:

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

Open in new window

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 20390733
OK, EE character conversion was changed...
0
 

Author Comment

by:sasha85
ID: 20405408
sorry , i tried those codes and nothing work right...
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20405436
sasha85,

did you try my code? seems to work when i tried it..
0
 

Author Comment

by:sasha85
ID: 20405458
<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
 
LVL 21

Expert Comment

by:nizsmo
ID: 20405477
do you have the correct fonts installed? I presumed I got ????? because I do not have the fonts installed.
0
 

Author Comment

by:sasha85
ID: 20405607
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
 
LVL 21

Expert Comment

by:nizsmo
ID: 20405721
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
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 20405814
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 20406432
So you say my proposal with <?php = htmlentities($yourIvritString) ?> did not work for Hebrew?
Can you confirm that?

0
 

Author Comment

by:sasha85
ID: 20409916
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 20415443
Ah! OK, then you need a solution in VBScript for your ASP page, right?
0
 

Author Comment

by:sasha85
ID: 20421935
nope...i am using pure asp...no vb...it is running on asp server
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 20423612
ASP you can script in JScript or VBScript.
What do you prefer?
0
 

Author Comment

by:sasha85
ID: 20424108
never used jscript...i prefer vbs...but i see that any solution will be syntax longer than the one i wrote...
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 20429200
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
 

Author Comment

by:sasha85
ID: 20432202
no no...zvonko...don;t do this...i will use my div rather...it is much shorter...thanks man
0
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 800 total points
ID: 20434802
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question