I'm queuing all mails and so store them in the database. My problem is that a mail with some French text in it failed to save properly around a simple " à ". After digging a bit through the code and searching for a solution I found this (not related to drupal but basically the same issue):

I played around with chr(194).chr(160) and got it working, unfortunately I'm on holidays now so I won't be able to provide a patch. But I don't even know where I have to replace the non-breaking space, just everywhere?



elpuzzo’s picture

Component: Module compatibility » Code

Had the same issue with   in posts that were sent via email.
Replacing "chr(160)" with "chr(194).chr(160)" html_to_text.inc seems to fix it.

phKU’s picture

I confirm the issue: non breaking spaces have to be inserted in utf-8 format. Otherwise the back conversion to space alters characters whose are composed with the chr(160) code, for e.g. the « à » character composed by utf-8 code chr(195) + chr(160). To fix it, in html_to_text.inc:
at line #128, replace:
$text = str_replace(chr(160), ' ', trim($text, $eol));
$text = str_replace(chr(0xC2) . chr(0xA0), " ", trim($text, $eol));
and at line #174, replace:
$text = str_replace(' ', chr(160), $text);
$text = str_replace(' ', chr(0xC2) . chr(0xA0), $text);

jcisio’s picture

Issue summary: View changes
Status: Active » Needs review
1.28 KB

I don't think the first convert is necessary, because there are people who really want nbsp instead of sp, even in plain text email.

jcisio’s picture

Version: 6.x-2.34 » 6.x-2.x-dev
das-peter’s picture

Had the same issue using mailsystem 7.x with maillog that stores the mails for debugging purposes.

tregismoreira’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
12.27 KB

I had same issue using Mailsystem 7.x-2.x + HTMLMail. The best approach I could find is to use mb_convert_encoding(chr(160), 'UTF-8', 'HTML-ENTITIES') instead of chr(160). It worked for me.

Here's my patch against to 7.x-2.x-dev.

monstrfolk’s picture

Status: Needs review » Reviewed & tested by the community

Patch works. Thanks.

monstrfolk’s picture

Status: Reviewed & tested by the community » Needs work

One side effect...makes some lines break before they should.

monstrfolk’s picture

monstrfolk’s picture

Status: Needs work » Needs review