Skip to content

Commit

Permalink
Merge pull request #6586 from BBasile/issue-18993
Browse files Browse the repository at this point in the history
fix issue 18993 (REG ~master) - toLower is broken for UTF chars
  • Loading branch information
wilzbach authored Jun 18, 2018
2 parents 8d4e394 + 7dc672f commit 238fb76
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -9003,16 +9003,18 @@ if (isSomeString!S || (isRandomAccessRange!S && hasLength!S && hasSlicing!S && i
{
import std.array : appender, array;
import std.ascii : isASCII;
import std.utf : byDchar;
import std.utf : byDchar, codeLength;

alias C = ElementEncodingType!S;

auto r = s.byDchar;
for (size_t i; !r.empty; ++i, r.popFront())
for (size_t i; !r.empty; i += r.front.codeLength!C , r.popFront())
{
auto cOuter = r.front;
ushort idx = indexFn(cOuter);
if (idx == ushort.max)
continue;
auto result = appender!(ElementEncodingType!S[])();
auto result = appender!(C[])();
result.put(s[0 .. i]);
result.reserve(s.length);
foreach (dchar c; s[i .. $].byDchar)
Expand Down Expand Up @@ -9062,6 +9064,11 @@ if (isSomeString!S || (isRandomAccessRange!S && hasLength!S && hasSlicing!S && i
assert(s == "abcdefghij");
}

@safe unittest // 18993
{
static assert(`몬스터/A`.toLower.length == `몬스터/a`.toLower.length);
}


// generic toUpper/toLower on whole range, returns range
private auto toCaser(alias indexFn, uint maxIdx, alias tableFn, alias asciiConvert, Range)(Range str)
Expand Down

0 comments on commit 238fb76

Please sign in to comment.