Problem/Motivation
PHP wordwrap() function handles UTF-8 incorrectly. It trims Unicode texts twice shorter. There are no mb_ version either.
I compilated a drupal_wordwrap() function from php.net examples, and supplied it with $cut parameter. Tested on Russian, works perfect.
I guess, the phpversion() checking is redundant, but I have no idea how to tweak this part, so I'm ready to listen any suggestion.
Please review, the patch.
Steps to reproduce
Proposed resolution
Remaining tasks
First, write a test for MailFormatHelper using UTF-8.
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
Comments
Comment #1
neochief commentedPatch for 6.x, just in case.
Comment #2
lilou commentedComment #4
neochief commentedUpdate for TB.
Comment #6
OnkelTem commentedUpdating patch for D6.13
Comment #7
OnkelTem commentedThere is an error in the patch in drupal_wordwrap function.
Add 'u' modifier to this code:
to get:
Not tested much, but this is fixing breaking my line:
РАЗВИТИЕ КОРПОРАТИВНОГО САЙТА => � АЗВИТИЕ КО� ПО� АТИВНОГО САЙТА
Comment #8
neochief commentedThanks for the addition, updating patch for 7.x (let's port it to earlier version, when 7.x will be ready).
Comment #10
sreynen commentedAutomated tests failed to run, setting back to needs review to try again.
Comment #11
sreynen commentedAutomated tests failed to run, setting back to needs review to try again.
Comment #13
neochief commentedSomething wrong with the test. Patch isn't fail, it's just fail to test.
Comment #16
kaakuu commentedSubscribed.
Comment #17
good_man commentedSubscribed.
Comment #18
good_man commentedI see that the last failed test gave the following message:
Ensure the patch only contains unix-style line endings.
I reviewed it and all end of line characters are Unix-style. maybe you resubmit it to see if it'll pass this time.
Comment #19
grendzy commentedComment #20
Antton commentedAs a result of using the patch - at the end of each line by two spaces and transfer to the next line.
As a result, when reading the letter e-mail client displays it as a message in one line.
Comment #21
grendzy commentedComment #22
Antton commentedThe patch fixes the problstrong, but partly. At the end of each row are whitespace. A problstrong with the transfer lines in the mail client Mozilla Thunderbird. Mozilla Thunderbird prolongs string if the end of the line is whitespace.
Original letter:
Shows Mozilla Thunderbird:
How to fix a patch to the end of the line, where we need a new line, - no whitespace? Thanks.
Comment #23
grendzy commentedPlease do not change the version. Bugs must be fixed in the latest development version before backporting.
http://drupal.org/node/10262
Comment #24
Antton commentedSolved the problem
Added the line:
$ return = trim ($ return);Before:
return $ return;It removes the trailing spaces in text strings __
Now Mozilla Thunderbird normally displays the letter.
Comment #25
sreynen commentedChanging status and version back; doesn't sound like this is fixed.
Comment #26
damien tournoud commentedComment #27
pillarsdotnet commentedThere is a UTF-8 compatible wordwrap included with #299138: Improve \Drupal\Core\Utility\Mail::htmlToText()
Comment #28
Andreyy commenteddrupal_wordwrap.patch queued for re-testing.
Comment #29
good_man commentedTagging for D8 Multilingual Initiative.
Comment #30
gábor hojtsyInvalid patch format, since the patch does nto apply anymore. Also needs tests.
Comment #31
gábor hojtsyComment #32
gábor hojtsyAdding base language system tag.
Comment #33
hazaImplemented that over D8. Let's see what the bot thinks about that...
(no tests added for now)
Comment #35
maximn commentedComment #36
maximn commentedPatch for for D7
Comment #38
marcingy commentedPlease keep version at d8.
Comment #39
jair commentedNeeds reroll
Comment #40
superspring commentedThis patch is a tidied up version of some of the previous patches.
- Code has been rearranged (into the Unicode class)
- More wordwrap uses have been found and updated
- Code has been commented far more.
Comment #42
ekl1773Does not need reroll! Applies to Head at 902b741
Comment #43
oriol_e9g#40: unicode_safe_wordwrap-540228-40.patch queued for re-testing.
Comment #53
quietone commented@neochief, thanks for the report and the initial patch.
Closed #2754669: Chinese/Japanese text wrapping as a duplicate.
This still seems to be valid. I didn't see a test of UTF8 for MailFormatHelper.
Talked to darvanen in #bugsmash and we weren't able to figure out what the stringwrappers are doing.
As a first step, let's get a test of MailFormatHelper with a UTF-8 source.
Comment #57
chi commentedStill relevant in Drupal 11.