Support » Fixing WordPress » problems with ISO8859-1 and UTF-8 in forms

  • Hi.
    My WP blog uses UTF-8 as text format, but norwegian characters show up as strange characters. After doing some research i ended up adding: AddDefaultCharset utf-8 to my .htaccess file and that solved all problems.
    I have a contact form and this form now sends mail where Norwegian letters are strange. If i make a .htaccess file in the folder where the kontakt.php file is resided (AddDefaultCharset ISO-8859-1), mail will be OK, but the content containing Norwegian letters on that page will look strange.
    So what solves my character problems on my web makes the same problems on my mail and what solves my mail problems makes the same problems on the web.
    How can I solve this? What is the problem here?

Viewing 6 replies - 1 through 6 (of 6 total)
  • What you describe is one of the problems I’d like to understand better myself. The solution isn’t to throw out utf-8 in your blog. I believe you could start looking at your mail form. If the script behind it insists on sending iso-8859-15 code (in any case, -1 is obsolete for Europeans), the clash might come from there.
    I have a notification script that first did the same yours did, but after I added

    $headers .= "Content-type: text/plain; charset=utf-8\r\n";
    $headers .= "Content-Transfer-Encoding: 8bit\r\n";

    to the part that generates the email headers, they come through fine.
    But this is pure trial and error. I can’t claim to understands all of this.

    Hi and thanks for a reply. Can we discuss this for a bit? maybe we get to the bottom of this.
    I have not tried your solution as I don’t know how to implement it. Could you please explain more?
    I added accept-charset=”ISO-8859-1″ to my <form> and that made all mails from Firefox come out OK, but still problems from IE users.
    Here is my form:

    <form accept-charset="iso-8859-1" action="contactscript.php" method="post">
    Navn:<input type="text" name="navn" size="20" maxlength="20" /> E-post:<input type="text" name="epost" size="30" maxlength="30" />
    Emne:<input type="text" name="emne" size="30" maxlength="30" />
    Tekst: <textarea name="tekst" cols="55" rows="6"></textarea>
    <input type="submit" name="send" value="Send" />

    and here is the script sending the mail:

    $name = stripslashes($navn);
    $email = stripslashes($epost);
    $text = stripslashes($tekst);
    $subject = stripslashes($emne);
    mail('',$subject,$text,"From: $name <$email>");

    It is really strange forms filled with Firefix is OK while IE is not.. what does this tell us?

    Hi again serendipity
    I figured out how to change the headers (long live
    That solved my problem..
    BUT (heheh)
    now mails from Firefox clients are scrambeled.. that is, norwegian letters does not show up at all.
    strange strange…

    I’m unclear about what you’re doing now. Added “accept-charset iso-8859-1” (why -1 and not -15? i’ll never understand that… ) and set the same as the charset in the header? Or both to utf-8?
    Have you looked at the headers of the email you receive?
    And … don’t take me wrong, but it’s much more pleasant to discuss this with someone who’s not posting as “anonymous”. You’d also get more people interested in your problem.

    Hi again Serendipty.
    I had a login I just had lost my password and had problems finding the “lost password?” link on this forum. Now I found it so here you have me as a member.
    I added accept-charset to the form (look at code abowe). Why -1 and not -15? I dunno really, but all referencec to Norwegian in different documents point to -1. Why -15?
    Also, I have removed the accept-charset and that fixed the faulty characterset when using Firefox. So everything is alright now, although I don’t understand why.
    To sum up:
    * Whithout your header info, WITH accept-charset=ISO-8859-1
    the server send faulty mails when using IE
    the server send OK mails when using Firefox
    * With your header info, WITH accept-charset=ISO-8859-1
    the server send OK mails when using IE
    the server send faulty mails when using Firefox
    * Without both accept-charset and your header
    both IE and Firefox fails. But OK if AddDefaultCharset UTF-8 in .htaccess
    So are we any closer? Does anybody else have a clue to what’s going on?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘problems with ISO8859-1 and UTF-8 in forms’ is closed to new replies.