Hi, I need some help here!! Please

M

Martin Honnen

sahm said:
How to assign Unicode charter (like arabiac) to varibl in javascript

Are you asking about Arabic characters? You can use a text editor that
supports Unicode and save your HTML documents with embedded scripts or
your external script files as UTF-8 then you can use the characters
literally e.g.

var s = "بالحرو٠العربية";

Or you can use Unicode escape sequences in JavaScript string literals e.g.

var s =
"\u0628\u0627\u0644\u062D\u0631\u0648\u0641\u0020\u0627\u0644\u0639\u0631\u0628\u064A\u0629";

Finally there is String.fromCharCode e.g.

var s = String.fromCharCode(1576, 1575, 1604, 1581, 1585, 1608, 1601,
32, 1575, 1604, 1593, 1585, 1576, 1610, 1577);
 
S

sahm

Martin Honnen & Evertjan. Thanks for your Reply

In my web page javascript code get the arabiac charter from html text
box and I'm try to use Ajax in my code every time I try to send the
arabiac charter it wont accept it
Please help in this
 
E

Evertjan.

sahm wrote on 26 nov 2006 in comp.lang.javascript:
Martin Honnen & Evertjan. Thanks for your Reply

In my web page javascript code get the arabiac charter from html text
box and I'm try to use Ajax in my code every time I try to send the
arabiac charter it wont accept it

character?

[please always quote on usenet]

Perhaps show some code?
 
A

ASM

sahm a écrit :
How to assign Unicode charter (like arabiac) to varibl in javascript

About arabiac I don't know its table-charset

in french :

é = \xe9 where e9 is Hexa code for é


The best is to write you code in utf-8 directly in arabian in your vars

And, of course, headers sent with html file tells it is in utf-8
 
V

VK

sahm said:
In my web page javascript code get the arabiac charter from html text
box and I'm try to use Ajax in my code every time I try to send the
arabiac charter it wont accept it

JavaScript "speaks" Unicode only: respectively it "sees" any page
content as Unicode characters: irrelevant to the encoding used to serve
the page: 8859-6, UTF-8, or something else. I strongly presume that in
your strings handling you are trying to use HTML entities or %-escape
sequences. That is the most common mistake. But as suggested an actual
code sample (or a URL) would greatly help.
 
M

Martin Honnen

sahm said:
In my web page javascript code get the arabiac charter from html text
box and I'm try to use Ajax in my code every time I try to send the
arabiac charter it wont accept it

Please show the relevant code and explain in more detail what "it won't
accept it" means. Do you get an error message? If so which one? Is the
character not correctly received on the server? How exactly are you
trying to send it to the server, what server side language/framework do
you use to receive it? There are a lot of settings that matter, for
instance how you encode the characters you send to the server, how the
server decodes them.
 
S

sahm

Here is the code
This is HTML code
//////////////////////////////
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AJAX with PHP: Quickstart</title>
<script type="text/javascript" src="quickstart.js"
charset="UTF-8"></script>
<head lang="ar">
<meta http-equiv="Content-Language" content="ar-bh">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1256">
</head>
<body onload='process()'>
Server wants to know your name:
<input type="text" id="myName" />
<div id="divMessage" />


</body>
</html>
///////////////////////////////


This is javascript code
///////////////////////////////

var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
var xmlHttp;

if(window.ActiveXObject)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlHttp = false;
}
}

else
{
try
{
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
xmlHttp = false;
}
}

if (!xmlHttp)
{
alert("Error creating the XMLHttpRequest object.");
}
else
{
return xmlHttp;
}
}

function process()
{
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{
//name =
String.fromCharCode(encodeURIComponent(document.getElementById("myName").value));
//alert(name);
name = encodeURIComponent(document.getElementById("myName").value);
xmlHttp.open("GET", "quickstart.php?name=" + name, true);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.send(null);
}
else
setTimeout('process()', 1000);
}

function handleServerResponse()
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
xmlResponse = xmlHttp.responseXML;
xmlDocumentElement = xmlResponse.documentElement;
helloMessage = xmlDocumentElement.firstChild.data;
document.getElementById("divMessage").innerHTML =
'<i>' + helloMessage + '</i>';
setTimeout('process()', 1000);
}
else
{
alert("There was a problem accessing the server: " +
xmlHttp.statusText);
}
}
}


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

This is PHP code
///////////////////////////////
<?php
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
echo '<response>';
$name = $_GET['name'];
$userNames = array('CRISTIAN', 'BOGDAN', 'شالم', 'حسين',
'YODA');
if (in_array(strtoupper($name), $userNames))
echo 'Hello, master ' . htmlentities($name) . '!';
else if (trim($name) == '')
echo 'Stranger, please tell me your name!';
else
echo htmlentities($name) . ', I don\'t know you!';
echo '</response>';
?>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 
M

Martin Honnen

sahm said:
This is PHP code

Which PHP version do you have on the server? Have you thought about
sending XML to the server? That way you might have better chances to
correctly submit the Arabic characters as XML supports Unicode and as
PHP's XML parser supports UTF-8.

Your original request sounded as if you wanted to insert Arabic
characters in JavaScript program code but now it looks as if you simply
read out the content of a text input which has Arabic characters. That
should not pose any problems in modern browsers in terms of JavaScript,
the tricky issue is sending stuff to the server and receiving stuff from
the server and getting the encoding/decoding right, in particular with
PHP which treats its strings as sequences of bytes and does not have
support for Unicode unless you use extensions like mbstring.
 
S

sahm

Martin said:
Which PHP version do you have on the server? Have you thought about
sending XML to the server? That way you might have better chances to
correctly submit the Arabic characters as XML supports Unicode and as
PHP's XML parser supports UTF-8.

Your original request sounded as if you wanted to insert Arabic
characters in JavaScript program code but now it looks as if you simply
read out the content of a text input which has Arabic characters. That
should not pose any problems in modern browsers in terms of JavaScript,
the tricky issue is sending stuff to the server and receiving stuff from
the server and getting the encoding/decoding right, in particular with
PHP which treats its strings as sequences of bytes and does not have
support for Unicode unless you use extensions like mbstring.


More explain please
And how can I send sending XML to php server
I'm new here Please help me
 
M

Martin Honnen

sahm said:
More explain please
And how can I send sending XML to php server

You can build an XML DOM document with script and pass that to the send
method of the XMLHttpRequest object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top