Results 1 to 2 of 2

Thread: Special characters

  1. #1
    Join Date
    Apr 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Special characters

    What is it that makes an ajaxrequest to a PHP script, convert all special characters (like æ,ø,å ) to weird letters (like §,|,&,#), and when i "echo" the same sting back to the ajax/javascript that sendt the string to the PHP script, it's back to normal (æ,ø,å). Okey, easy to understand? Well, se:

    ajaxpage: PHP page: ajaxpage:
    Æ Ø Å ---------> § | # ----> Æ Ø Å

    but I want to save the string to a file, and the file just gets these "§ | #"-letters

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's probably because your PHP script uses a different character encoding to your Javascript pages. I remember I had this problem trying to upload some shift_JIS hiragana to a PHP script. I was using Java, though, so I just changed the encoding. I don't know if Javascript provides a means to do this. Of course, you could always play around with the recode_string() function, but I don't know if the encoding of the string sent from Javascript would always be the same. We'd have to ask Mike on that one, methinks.

    Another option is to use escape() on the string in the Javascript, then urldecode() on the PHP side.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •