Problem with AJAX and Special Chars (Perl, MySQL 4)

D

design4future

Hello

I've developed an PHPMYADMIN lookALike in AJAX,Perl,Mysql.
All owrks fine except the french, german special chars.


AJAX-Part:
At the moment i create an XMLhttpRequest-Object with
new XMLHttpRequest();
or
new ActiveXObject("Microsoft.XMLHTTP");

now the function opens the connection ...
obj.open("POST", URL);

then i add an HTTPheader with
obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded;
charset=UTF-8");

now i call the send methode
obj.send(CGIVars);
The CGIVars are urlencoded with "encodeURIComponent"


thats the AJAX-Part


In Perl:
Now i fetch the Params with
CGI->param("postVarname");

and store them over DBI & DBD::mysql into the database.
This works fine too. It occurs no error.


But the output from chars like "äöü" in the database are corrupted.
They look like "ää".
I have check this with phpmyadmin


The



Where is the bug?
When i convert the values over encode_utf8() they are damaged too.
+ But I think they are already in UTF8 or not? Perl handles all
internal strings in UTF8 or not?
+ How can i check which encoding is used in Perl?
+ Is the Ajax-Header correct?
+ Javascript sends all the data via POST or GET in UTF8, or not?


SYSTEM-Information:
Windows XP SP1
Apache 1.3
Perl 5.8.0 Build 806
Mysql 4.1.18-nt (collation: utf8_unicode_ci)
DBI Version 1.48
DBD-mysql Version 3.00002
phpmyadmin 2.7.0-pl2
Checked with Firefox 1.5.01




Thanks for every suggestion.


best regards,

robert
 
M

Michael Kindermann

design4future said:
Hello

I've developed an PHPMYADMIN lookALike in AJAX,Perl,Mysql.
All owrks fine except the french, german special chars.


AJAX-Part:
At the moment i create an XMLhttpRequest-Object with
new XMLHttpRequest();
or
new ActiveXObject("Microsoft.XMLHTTP");

now the function opens the connection ...
obj.open("POST", URL);

then i add an HTTPheader with
obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded;
charset=UTF-8");

now i call the send methode
obj.send(CGIVars);
The CGIVars are urlencoded with "encodeURIComponent"


thats the AJAX-Part


In Perl:
Now i fetch the Params with
CGI->param("postVarname");

and store them over DBI & DBD::mysql into the database.
This works fine too. It occurs no error.


But the output from chars like "äöü" in the database are corrupted.
They look like "��".
I have check this with phpmyadmin


The



Where is the bug?
When i convert the values over encode_utf8() they are damaged too.
+ But I think they are already in UTF8 or not? Perl handles all
internal strings in UTF8 or not?
+ How can i check which encoding is used in Perl?
+ Is the Ajax-Header correct?
+ Javascript sends all the data via POST or GET in UTF8, or not?


SYSTEM-Information:
Windows XP SP1
Apache 1.3
Perl 5.8.0 Build 806
Mysql 4.1.18-nt (collation: utf8_unicode_ci)
DBI Version 1.48
DBD-mysql Version 3.00002
phpmyadmin 2.7.0-pl2
Checked with Firefox 1.5.01




Thanks for every suggestion.


best regards,

robert
I had a similar Problem with html code and decoding helped.
$text = decode("utf8", $text);

kimi
 

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,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top