Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi,
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):
http://trac.roundcube.net/ticket/1484429#trac-change-5-1190124040000000
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?
Thanks,
sb
Comment | File | Size | Author |
---|---|---|---|
#11 | mailsystem-non_breaking_space_utf8-1976716-11.patch | 566 bytes | nitheesh |
#9 | mailsystem-non_breaking_space_utf8-1976716-9.patch | 900 bytes | monstrfolk |
#6 | mailsystem-non_breaking_space_utf8-1976716-6.patch | 12.27 KB | tregismoreira |
#3 | mailsystem-1976716-nbsp.patch | 1.28 KB | jcisio |
Comments
Comment #1
m-p-j CreditAttribution: m-p-j commentedHad 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.
Comment #2
phKU CreditAttribution: phKU commentedI 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));
with
$text = str_replace(chr(0xC2) . chr(0xA0), " ", trim($text, $eol));
and at line #174, replace:
$text = str_replace(' ', chr(160), $text);
with
$text = str_replace(' ', chr(0xC2) . chr(0xA0), $text);
Comment #3
jcisio CreditAttribution: jcisio commentedI don't think the first convert is necessary, because there are people who really want nbsp instead of sp, even in plain text email.
Comment #4
jcisio CreditAttribution: jcisio commentedComment #5
das-peter CreditAttribution: das-peter at Cando commentedHad the same issue using mailsystem 7.x with maillog that stores the mails for debugging purposes.
Comment #6
tregismoreira CreditAttribution: tregismoreira commentedI 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 ofchr(160)
. It worked for me.Here's my patch against to 7.x-2.x-dev.
Comment #7
monstrfolk CreditAttribution: monstrfolk commentedPatch works. Thanks.
Comment #8
monstrfolk CreditAttribution: monstrfolk commentedOne side effect...makes some lines break before they should.
Comment #9
monstrfolk CreditAttribution: monstrfolk commentedComment #10
monstrfolk CreditAttribution: monstrfolk commentedComment #11
nitheesh CreditAttribution: nitheesh at O8 commentedInstead of replacing all the occurrences of char(160), just decode the formatted string and replace the non-breaking space character before appending it back to the result set.