Re: [FX.php List] (mail) - problems with Æ - Ø - Å

Erik Andreas Cayré erik at cayre.dk
Tue May 1 18:35:09 MDT 2007


Den 02/05/2007 kl. 6.29 skrev Baard Belsaas:

> Hi Erik
>
> I try this in my site, but the unhtmlentities-code give me a Fatal  
> error:
> Call to undefined function: unhtmlentities() in
> /Library/WebServer/Documents/mailtest.php on line 3

Sorry, my bad.
I had been using my own function unhtlmentities() before I discovered  
it's already buildt in to PHP.

It should work if you replace unhtmlentities() with html_entity_decode()

> The same happens on another server with the html_entity_decode, but  
> not on
> my local mac. Do I have to do some setup in the php to get this work?

It seems the server may have an older version of PHP which does not  
have the html_entity_decode() function...
Odd since the function has been in PHP since v. 4.3.0: http:// 
www.php.net/manual/en/function.html-entity-decode.php

If you can't get the PHP version on the server upgraded (strongly  
recommended!), you could do as I did: define your own function, and  
use that instead.
The code is taken directly from the PHP manual page linked above, and  
should be equivalent to the built-in function (only ISO-8859-1)...

function unhtmlentities($string)
{
     // replace numeric entities
     $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\ 
\1"))', $string);
     $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string);
     // replace literal entities
     $trans_tbl = get_html_translation_table(HTML_ENTITIES);
     $trans_tbl = array_flip($trans_tbl);
     return strtr($string, $trans_tbl);
}

Hope you get it working
/Erik

>
> /Baard
>
>
> På 01-05-07 07:34, skrev "Erik Andreas Cayré" <erik at cayre.dk>:
>
>>
>> Den 01/05/2007 kl. 6.15 skrev Baard Belsaas:
>>
>>> Hello, I have a send mail in my fx.php-site. I use the php-code "
>>> mail()".
>>> When there is a æ/Æ, ø/Ø or å/Å in the data from FileMaker, the
>>> text in the
>>> mail come with "wrong text". The letters print like this:
>>> æ = &#230;
>>> Æ = &#198;
>>> ø = &#248;
>>> Ø = &#216;
>>> å = &#229;
>>> Å = &#197;
>>>
>>> Someone out there nowes anything about this? Please...
>>>
>>>
>>> Baard
>>
>> Hi Baard,
>>
>> The text from Filemaker is HTML-encoded by FX.php, ready to show on a
>> webpage.
>>
>> Use html_entity_decode() on the text going into you email. It uses
>> ISO-8859-1 by default, which is fine for most purposes.
>>
>> Example:
>> $to = html_entity_decode($_SESSION['order']['customername'] . ' <' .
>> $_SESSION['order']['customeremail'] . '>');
>> $subject = 'Your order ' . $_SESSION['order']['id'];
>>
>> // Convert HTMLencoding to ISO 8859-1
>> $message = unhtmlentities($message);
>>
>>
>> // headers
>>
>> $mailheaders = 'From: websitename <noreply at domain>' . '
>> ' .'Reply-To: Customer Service <service at domain>' . '
>> ' .'Bcc: secretrecipient <007 at otherdom>' . '
>> ' . 'MIME-Version: 1.0' . '
>> ' . 'Content-type: text/plain; charset=ISO-8859-1' . '
>> ' . 'Content-Transfer-Encoding: quoted-printable' . '
>> ' . 'X-Mailer: MyMagicMailer';
>>
>> // send mail receipt
>>
>> mail($to, $subject, wordwrap($message, 70), $mailheaders);
>>
>> Best regards
>>
>> ---
>> Erik Andreas Cayré
>> Spangsbjerg Møllevej 169
>> 6705 Esbjerg Ø
>>
>> Privat Tel: 75150512
>> Mobil: 40161183
>>
>> ---
>> »Interesse kan skabe læring på en skala sammenlignet med frygt, som
>> en nuklear eksplosion i forhold til en kineser.«
>> --Stanley Kubrick
>>
>> »Kun p....sure mennesker kan ændre verden. Innovation skabes ikke af
>> 'markedsanalyse', men af folk, der er afsindigt irriterede over
>> tingenes tilstand «
>> --Tom Peters
>>
>> »Hvis du ikke kan forklare det simpelt, forstår  du det ikke godt  
>> nok.«
>> -- Albert Einstein
>>
>> »Hvis du ikke har tid til at gøre det rigtigt, hvornår vil du så have
>> tid til at lave det om?«
>> -- John Wooden, basketball coach
>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



---
Erik Andreas Cayré
Spangsbjerg Møllevej 169
6705 Esbjerg Ø

Privat Tel: 75150512
Mobil: 40161183

---
»Interesse kan skabe læring på en skala sammenlignet med frygt, som  
en nuklear eksplosion i forhold til en kineser.«
--Stanley Kubrick

»Kun p....sure mennesker kan ændre verden. Innovation skabes ikke af  
'markedsanalyse', men af folk, der er afsindigt irriterede over  
tingenes tilstand «
--Tom Peters

»Hvis du ikke kan forklare det simpelt, forstår  du det ikke godt nok.«
-- Albert Einstein

»Hvis du ikke har tid til at gøre det rigtigt, hvornår vil du så have  
tid til at lave det om?«
-- John Wooden, basketball coach




More information about the FX.php_List mailing list