We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2a2cb32 + 6c5f8a4 commit 2955c8cCopy full SHA for 2955c8c
std/utf.d
@@ -3599,8 +3599,27 @@ template byUTF(C) if (isSomeChar!C)
3599
if (pos == fill)
3600
{
3601
pos = 0;
3602
- fill = cast(ushort)encode!(UseReplacementDchar.yes)(
3603
- buf, decodeFront!(UseReplacementDchar.yes)(r));
+ auto c = r.front;
+
3604
+ if (c <= 0x7F)
3605
+ {
3606
+ fill = 1;
3607
+ r.popFront;
3608
+ buf[pos] = cast(C) c;
3609
+ }
3610
+ else
3611
3612
+ static if (is(RC == dchar))
3613
3614
+ fill = cast(ushort) encode!(UseReplacementDchar.yes)(buf, c);
3615
3616
3617
3618
3619
+ fill = cast(ushort) encode!(UseReplacementDchar.yes)(
3620
+ buf, decodeFront!(UseReplacementDchar.yes)(r));
3621
3622
3623
}
3624
return buf[pos];
3625
0 commit comments