Needs work
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
25 Sep 2017 at 14:11 UTC
Updated:
10 Mar 2026 at 17:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
mile23Replaced side-effects with do-while.
Comment #4
dawehnerI don't think we should have to do that. #2849669: Fix \Drupal\Component\Utility\Unicode() because of the Symfony mbstring polyfill will basically empty this file completely.
Comment #5
alexpottWell \Drupal\Component\Utility\Unicode::truncateBytes() has no mb_* equivalent so I guess this issue can proceed.
Comment #6
borisson_While this is more readable, I still wouldn't call this simple. However, it is better compared to the situation we had before.
This method has specific unit test coverage that confirms this still works.
That means this can go to RTBC, also based on #5's answer to #4.
Comment #7
alexpottI've added some test cases and found a bug in the difference between the way this works for unicode and non-unicode characters.
I think we should add the following test cases here:
because this explicitly proves the counting backwards is working. I also think we should create a followup to fix the bug when
is set to a negative number. In that issue we should discuss what to do. I think it might be correct just to ensure that $len is positive and deprecate the incorrect negative behaviour. As you can see from the negative behaviour test for unicode it currently incorrectly chops up the string resulting in a � character.
Comment #21
quietone commentedCreated an MR from the existing patch and comments. This also removes an @todo, which is nice.
Comment #22
quietone commentedComment #23
smustgrave commentedSmall comment on the MR.