Hi Roberto,
Thanks for your help. I did as you said and alert the sent text. Then it
shows the hebrew strings without any modification. But it didn't go to the
database until I put these lines before execute the mysql insert query.
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
mysql_query("SET character_set_database=utf8");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_server=utf8");
Then It works nicely. But I thought only neccessity for inserting UNICODE
string to a database is create it in utf8_coalition .
Anyway problem solved.
Thanks & regards,
Manjula
On Mon, Oct 27, 2008 at 10:53 AM, Roberto Bouzout (tito) <[EMAIL
PROTECTED]>wrote:
> I need to know how can I send an unicode text like Hebrew through
>> JAVASCRIPT (encode) and get it from PHP (decode it) to save it to a
>> MySQL database.
>>
>
> I do this:
>
> var url = 'http://www.domain.com/some/file?decoded='+X_EncodeUTF8('
> מחשבים');
> var browser = window.getBrowser();
> var tab = browser.addTab(url);
>
> function X_EncodeUTF8(string)
> {
> try
> {
> return encodeURIComponent(string);
> }
> catch(err)
> {
> try
> {
> return encodeURI(string);
> }
> catch(err)
> {
> return (string);
> }
> }
> }
>
> PHP:
> echo $_GET['decoded'];
>
> /*
>
> will print 'מחשבים'
> Assuming that your server 'serve' the file as UTF-8 ( see: "text/html;
> charset=UTF-"8 at the response headers)
>
> */
>
> I do the try and catch in the X_EncodeUTF8 because sometimes the argument
> maybe is malformed.. but valid.
>
> alert(decodeURI('http://example.net/canci%f3n/'))
>
> Error: URIError: malformed URI sequence
> Source file: Javascript Command
> Line: 1
>
> _______________________________________________
> Project_owners mailing list
> [email protected]
> https://www.mozdev.org/mailman/listinfo/project_owners
>
--
~Silver Surfer~
Surfing through time & space
http://risingofsilversurfer.blogspot.com/
_______________________________________________
Project_owners mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/project_owners