problem of character set encoding in php

Discussion in 'Programming' started by dr-support, Apr 6, 2007.

  1. #1
    I have a php form which submits information to an email. Everything works fine when dealing with 'normal' text. However, if a user submits "العربية", the resulting text displays as "د لله ".

    The website is in 3 languages (EN, FR, AR). Page encoding is unicode...


    Clearly it is an encoding problem, but I have looked around and cannot really see where to start to fix the problem. My php form submits to an external php file(contactus.php attached ), which in turn checks configuration information on an external text file.
     

    Attached Files:

    dr-support, Apr 6, 2007 IP
  2. dr-support

    dr-support Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    up up
     
    dr-support, Apr 6, 2007 IP
  3. dr-support

    dr-support Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    72 h
    up
    up

    please help
     
    dr-support, Apr 7, 2007 IP
  4. panfor

    panfor Peon

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Do you send txt or html e-mail?
     
    panfor, Apr 7, 2007 IP
  5. dr-support

    dr-support Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    txt mail normal
     
    dr-support, Apr 8, 2007 IP
  6. dr-support

    dr-support Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    no one can help me
     
    dr-support, Apr 10, 2007 IP
  7. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Firstly, let me get this off my chest: bumping posts is rude at the best of times, but when the only posts that you have ever made on the forum consist of your one post plus 4 bumps, that's just extremely rude. ESPECIALLY when your first bump was only 3 hours after the post.

    I was 'this close' to not replying, just for that.

    Anyway, essentially your problem is that the mail function doesn't do unicode. It seems as though email itself doesn't do unicode: it all comes down to ASCII and if you need to send unicode characters then it needs to be encoded. That's the feeling I get, anyway.

    I've never done anything like this before, but in the 2 minutes that it took me to Google 'sending unicode email via php' and looking through a few pages, I came across the following links that may help:
    - http://www.advogato.org/article/812.html
    - http://www.php.net/manual/en/function.mb-send-mail.php#29843
    - http://www.php.net/mb_send_mail

    Hope that helps.
     
    TwistMyArm, Apr 10, 2007 IP
  8. Rasczak

    Rasczak Peon

    Messages:
    131
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i think simple header() will solve your problem...

    use it like this, at the start of the page script:

    <?
    ...
    header('Content-Type: text/html; charset=utf-8');
    ...
    ?>


    of course replace utf-8 charset with your own used one...
     
    Rasczak, Apr 10, 2007 IP
  9. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Unless I'm mistaken, the problem is with bad characters in the emails, not the web page itself. If I'm right, the header function will have no effect.

    Can the OP confirm or deny this problem, please?
     
    TwistMyArm, Apr 10, 2007 IP