4 ms·
… does it work at a level higher than code units? From what I recall, leftpad's implementation worked at the level of code units, i.e., it padded to a particula
by deathanatos 10y ago
… does it work at a level higher than code units? From what I recall, leftpad's implementation worked at the level of code units, i.e., it padded to a particular number of code units, which is bugged for just about any use case one might apply it to.
That is, if you had the strings "a" and "é" (where the latter is "e\u0301") padded "equally" to length 3, leftpad would pad them approximately thusly:
__a
_é
> leftpad('e\u0301', 3, '_');
<- "_é"
- ygra 10y agoI very much doubt it. If it did, they would have to use grapheme clusters as measurement which nearly no one does. The easier way out is to just say »we have a trivial implementation that can only be used on strings where the developer already knows what's in it«.