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

Discussion in 'Perl Misc' started by design4future, Mar 16, 2006.

  1. 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
     
    design4future, Mar 16, 2006
    #1
    1. Advertising

  2. 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"
    >
    >
    > 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
     
    Michael Kindermann, Mar 16, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jonas Meurer
    Replies:
    6
    Views:
    868
    deelan
    Feb 23, 2005
  2. Horst Gutmann
    Replies:
    6
    Views:
    433
  3. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,295
    Tim Rentsch
    Sep 23, 2005
  4. Hongyu
    Replies:
    9
    Views:
    917
    James Kanze
    Aug 8, 2008
  5. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    235
    Dan Rogers
    Nov 16, 2004
Loading...

Share This Page