473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Hi, I need some help here!! Please

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

Nov 26 '06 #1
11 1809
sahm wrote:
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);

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 26 '06 #2
sahm wrote on 26 nov 2006 in comp.lang.javascript:
How to assign Unicode charter (like arabiac) to varibl in javascript

t = '&#65177' // ? [use alt+grey65177 to type]

<http://srufaculty.sru.edu/david.dailey/javascript/unicode.htm>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Nov 26 '06 #3
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

Nov 26 '06 #4
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?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Nov 26 '06 #5
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

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date
Nov 26 '06 #6
VK

sahm wrote:
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.

Nov 26 '06 #7
sahm wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 27 '06 #8
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.ge tElementById("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>';
?>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Nov 27 '06 #9
sahm wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 27 '06 #10

Martin Honnen wrote:
sahm wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/

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

Nov 27 '06 #11
sahm wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 28 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: tgregg6 | last post by:
I need help with my problem I am stuck and I don't know what to do!!! The problem is: This program calculates the charges for DVD rentals where current releases cost $3.5 and all others cast $2.50....
7
by: shaolinman829 | last post by:
I suck at regex's and I need a little hope. Hopefully there is a guru out there to help me on this one. I want to do a match on the following: one or more numeric characters zero or more...
2
by: Dalton | last post by:
This is all kind of in another language to, I mean I understand most of the words in relation to programming, but my field of work/study is IT. Anyways, on to the problem. I am working on my 5th...
3
by: DragonLord | last post by:
Here is the situation I am inserting rows into a datagridview and then using a function to group similar rows together based on a column. When I call to compare the lastrow with the current row...
3
by: squrel | last post by:
Hello everyone.. I m having a problem over here and dont knw wht else i have to do... i have 2 listviews (LvBill and LvBillPo) the data from LvBill wil go to the LvBillPo and if its fine then it...
15
by: squrel | last post by:
Hello All.. I m having some problem here.. i m using VB6 and SQLServer 2000... i m getting this error " statement invalid outside type block" i m sending u the code and the bold line is where i m...
16
by: squrel | last post by:
Hello everyone.. I need some help here... i m using VB6 and SQLServer2000... i have forms regarding some cases in courts and in my form i have two DTPicker called as Entrydate and Closedate......
12
by: squrel | last post by:
Hi everyone.. I have a form called "showreminder". in this form i have 2 dtpicker 1 command button and 1 datagrid : DTPfromDt and DTPtoDt and cmdshowreminder, and MSHFlexGrid1... this form has to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.