Page 1 of 1

Struggling with accented characters

Posted: Thu Apr 05, 2012 8:16 am
by greer
Hello,
We are building enrollment forms where users frequetly enter accented characters, which is fine until it comes time to email confirmations, etc.

When passing from vortex to sendmail, "hard-coded" accented characters show up fine, but in any variables the accented characters are garbled.

We have tried both emailing directly from the form submission, and writing the values to the database first, then retrieveing them, and sending. (The accented characters get written to the database fine, still look fine when retrieved, but look garbled once passed to sendmail.
--

example where USERNAME contains: àâäèéê

<SQL ROW "SELECT USERNAME FROM REGFORM where id = '4f7d6acd112d'"></SQL>
<send $USERNAME> // Produces: àâäèéê

<sum "%s" 'Prénom: ' $USERNAME>
<$BODY = $ret>
<$TO = 'user@email.com'>
<$FROM = 'user@unhcr.org'>
<$SUBJECT = 'testing'>

<exec BKGND /usr/lib/sendmail -t -n>
From: UNHCR <$FROM>
To: $TO
Subject: $SUBJECT
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
<fmt "%s" $BODY>
</exec>

// Produces: Prénom: ÃâäÃ&#776;Ã
// NB. (The "hard-coded" accent in "Prénom" shows correctly, but the user-submitted variable is garbled.)

--

Another example where data is used straight from an HTML form:

<form name="reg_form" id="reg_form" action="regsystem" method="post">
<input type="text" name="USERNAME" id="USERNAME" value="àâäèéê" />
<input type="submit" value="Soumettre" />
</form>

- and on the resulting page -

<if $USERNAME neq "">
<send $USERNAME> // Produces: àâäèéê

<sum "%s" 'Prénom: ' $USERNAME>
<$BODY = $ret>
<$TO = 'user@email.com'>
<$FROM = 'user@unhcr.org'>
<$SUBJECT = 'testing'>

<exec BKGND /usr/lib/sendmail -t -n>
From: UNHCR <$FROM>
To: $TO
Subject: $SUBJECT
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
<fmt "%s" $BODY>
</exec>

// Produces: Prénom: ÃâäÃ&#776;Ã

</if>

--

Any ideas on where we are going wrong? Thanks!

Struggling with accented characters

Posted: Thu Apr 05, 2012 8:50 am
by John
I think what is happening is that the HTML form submit send UTF-8 encoded accents, however in your email you are defining ISO-8859-1. If you try the email as UTF-8 instead of ISO-8859-1 does that work better?

Struggling with accented characters

Posted: Thu Apr 05, 2012 9:45 am
by greer
Hi John,

Thanks for that, it's given us enough information to solve the problem.

Cheers!

BTW, I posted this on behalf of one of my team as he was trying to use your Forgot Password link and it doesn't appear to be working.

Struggling with accented characters

Posted: Thu Apr 05, 2012 10:09 am
by mark
Also use <fmt "%s" ...> for from, to, and subject to avoid HTML escapement as you did for body.

Check your spam folder for mail from @master.com.