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

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

am 16.03.2006 17:42:15 von robert.henniger

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=3DUTF-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

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

am 16.03.2006 18:50:53 von Christian Kirsch

design4future wrote:
> 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"
>

Fine. But this is a MySQL group (coindicentally a german one, BTW).
People here are not supposed to understand AJAX, Javascript or PHP/Perl.

>
> But the output from chars like "äöü" in the database are corrupted.
> They look like "ää".
> I have check this with phpmyadmin
>
XML is by default encoded as UTF-8. And this is what you get. So where's
the problem?

>
> Where is the bug?

There is none.

> 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?

GO and ask in the appropriate news group. Since you don't have a MySQL
question, all this is off-topic here.

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

am 16.03.2006 23:55:26 von robert.henniger

Thanks for your reply.
But i asked for possible Mysql-errors or bugs too.
The chars are in the wrong format in the database. Thats an
Mysql-problem too. I dont know where the bug is!

Greetings

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

am 17.03.2006 08:43:47 von Christian Kirsch

robert.henniger@googlemail.com wrote:
> Thanks for your reply.
> But i asked for possible Mysql-errors or bugs too.
> The chars are in the wrong format in the database. Thats an
> Mysql-problem too. I dont know where the bug is!
>
Ask in a way that permits people here to reproduce the problem:
something they can try out using mysql (the command line client).

Und vielleicht wäre es ja für Dich doch einfacher, Deine Fragen hier (in
einer deutschsprachigen Newsgroup) auf Deutsch zu stellen?

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

am 17.03.2006 09:19:42 von Axel Schwenke

"robert.henniger@googlemail.com" wrote:

> Thanks for your reply.
> But i asked for possible Mysql-errors or bugs too.
> The chars are in the wrong format in the database. Thats an
> Mysql-problem too. I dont know where the bug is!

Zeichensatzprobleme sind typisch für kaputte [1] Applikationen, wenn
MySQL von pre-4.1 auf 4.1+ umgestellt wird. Es gibt im Handbuch ein
ausführliches Kapitel zum Thema Zeichensätze. Außerdem wurde das
Problem sowohl hier als auch nebenan in de.comp.lang.php.datenbanken
schon mehrfach durchgekaut.

Perl ist ein separates Problem. Mit 5.8 sind zwar die wesentlichen
Dinge auf UTF8 umgestellt, aber es gibt noch manchen Stolperstein.
Ich empfehle die Lektüre von perluniintro und perlunicode.


[1] "kaputt" im Sinne von "was kümmern mich Encoding-Deklarationen"


XL