Solved

hebrew with javascript

Posted on 2007-12-01
35
501 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
 

Author Comment

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

Author Comment

by:sasha85
ID: 20387569
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 100 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 100 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 100 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 200 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 200 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now