echo \yii\helpers\StringHelper::truncate('我<span>是aä¸</span>国人', 4, '...', 'UTF-8', true);
When I set param of $asHtml are true, the result is: "我 <span>是a </span>..."
But I'm expect is: "我<span>是aä¸</span>..."
| Q | A |
| --- | --- |
| Yii version | 2.0.9 |
| PHP version | 7.0.1 |
| Operating system | windows 10 |
Seems like unicode issues to me.
I'm sorry I don't have try to code from master, bacause I no any ideas
OK, I'll handle it.
That's not because of UTF-8 but because of adding extra spaces (why?) after tokens here
@samdark Thanks
Isnt this the cause of half widht characters? In the pull ruest for console::table the widh was also off.
Isnt this the cause of half widht characters?
No, it's not
Tests has extra spaces too https://github.com/yiisoft/yii2/blob/master/tests/framework/helpers/StringHelperTest.php#L110 that's funny.
@Alex-Code ping
https://github.com/yiisoft/yii2/pull/6207
I can't remember why I added the extra space there, not sure if it was more for truncating words within HTML that spaces would get lost.
I'll do some more tests to see if that space can be removed.
The main issue is with spaces getting removed by the truncate and truncateWords methods.
I've updated the truncateHtml method and added new tests which all pass.
Resolved by 6b88f2f
Most helpful comment
Tests has extra spaces too https://github.com/yiisoft/yii2/blob/master/tests/framework/helpers/StringHelperTest.php#L110 that's funny.
@Alex-Code ping
https://github.com/yiisoft/yii2/pull/6207