Hebrew with JavaScript server-side

Hello,

I am programming ASP using JavaScript as my server-side language.
I have the following code:

<%
Response.CharSet="windows-1255"

var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("GET", "http://www.simil.co.il/", false);
xmlHttp.send();
xmlDoc = xmlHttp.responseText;

Response.Write(xmlDoc);
%>

And I get the Hebrew (the page is in Hebrew) as ?? ??? ?? ?

How can this be solved?

Thanks.
shmulik15Asked:
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.

stanscott2Commented:
Whenever you send an XMLHTTPRequest, you need to specify a content-type, if you don't, UTF-8 is used.

In the line just following your xmlHttp.open code, enter this:

xmlHttp.setRequestHeader('text/xml', 'Windows-1255');

ZvonkoSystems architectCommented:
Does this help:

   Response.Write(Server.HTMLEncode(xmlDoc));


shmulik15Author Commented:
Thanks guys, but neither worked.

xmlHttp.setRequestHeader('text/xml', 'Windows-1255'); <- Returns "Unspecified error "
HTMLEncode returns it as Gibberish as well.
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

ZvonkoSystems architectCommented:
Stupid question: do you have correct displayed alefbet characters on the same page when you see question marks?
Can you see the page correct when you enter the simil URL in browser address bar?
shmulik15Author Commented:
Zvonko: Yes, Simil is a webpage that I own and it is displayed just fine, and yes, I can indeed see Hebrew on the page with the XMLHTTP Request.
stanscott2Commented:
Sorry, let's try again:

xmlHttp.setRequestHeader("Content-Type:text/html"; charset:ISO-8859-1");

I believe that the unicode character set supports Hebrew.  If not, try replacing "ISO-8859-1" with "Windows-1255".
shmulik15Author Commented:
stanscott2:
This returns an error as well.
ZvonkoSystems architectCommented:
Is here something for you: http://www.yuro2u.com/guides/XMLHTTP/
shmulik15Author Commented:
Thanks zvonko, but the example is in VBS, I need it in JS (and I don't know how to make it).
Any help with that would be appreciated.
ZvonkoSystems architectCommented:
There is no example that you could directly use. The link was more to enlight the background of the code page problem.
If you have any VB example I can easuly convert it for you to JScript.

By the way, my alias is &#1494;&#1456;&#1488;&#1461;&#1489; ;-)
shmulik15Author Commented:
Well, it says the problem with Hebrew is that it has to be encoded into UTF-8

This function should do it:

Function AsciiToUnicode(ByRef pstrAscii)
            For llngIndex = 1 To LenB(pstrAscii)
                        lstrUnicode = lstrUnicode & Chr(AscB(MidB(pstrAscii, llngIndex,1)))
            Next
            AsciiToUnicode = lstrUnicode
End function
(taken from the article you linked to)

ZvonkoSystems architectCommented:
OK, give me a second...
ZvonkoSystems architectCommented:
Here we go:

<html>
<head>
<title>Zvonko &#42;</title>
</head>
<body>
<div id="nickname">&#1494;&#1456;&#1488;&#1461;&#1489;</div>
<script>

function AsciiToUnicode(pstrAscii){
  var lstrUnicode = "";
  for(var i=0;i<pstrAscii.length;i++){
    lstrUnicode += String.fromCharCode(pstrAscii.charCodeAt(i));
  }
  return lstrUnicode;
}


alert(AsciiToUnicode(document.getElementById("nickname").innerHTML));
</script>
</body>
</html>

shmulik15Author Commented:
Ugh, the article said it should do the trick, which it didn't.
Any ideas would be appreciated.

By the way - Thank you very much for all the effort, Zvonko.
ZvonkoSystems architectCommented:
OK, let us start over.
When I store the browser html page from http://www.simil.co.il/ to local file and look at it then I see alefbet because the page encoding is switched (automaticaly) to "Hebrew (Windows)"
By the way, the Goggle ad on that page is then Giberisch.
Now, what page encoding schema does you browser show and use when you look at the page with or without the injected html?

shmulik15Author Commented:
The encoding is(was) Windows-1255 and I tried the UTF-8 method later. Neither worked.
ZvonkoSystems architectCommented:
Can you send me the URL with your test page to the email address in my profile?
Or is it a problem for you to publish the URL of the test page?

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
shmulik15Author Commented:
Sure, sending as email.
Michel PlungjanIT ExpertCommented:
Hi people - what was the result of this exercise? Would you please share?

alert("\u05DD\u05D5\u05DC\u05E9")
ZvonkoSystems architectCommented:
Uhps, sorry, I solved it but missed to update here.
Give me a second please...
ZvonkoSystems architectCommented:
OK, this is the working example:



<%@LANGUAGE="JavaScript"%>
<%

var xmlHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1");

xmlHttp.open("GET", "http://www.mechon-mamre.org/p/pt/pt3001.htm", false);

xmlHttp.send();
xmlDoc = xmlHttp.responseText;

Response.Write('<base href="http://www.mechon-mamre.org/p/pt/">');
Response.Write(xmlDoc);

%>



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.