std.stringbuffer

Steven Schveighoffer schveiguy at yahoo.com
Thu May 1 08:06:55 PDT 2008


"Janice Caron" wrote
> 2008/4/30 Me Here:
>>     char[] a = ...2000 chars from somewhere.
>>
>>     char[] field1 = a[ 312 .. 357 ];
>>     field1.toUpper();
>
> I've kind of lost track of the number of times I've said this in
> recent days, but...
>
> You cannot uppercase in place, because for any given dchar, c, the
> number of UTF-8 bytes required to express c may be different from the
> number of UTF-8 bytes required to express toupper(c).
>
> If any of you have plans to uppercase or lowercase UTF-8 in place,
> forget that now. It just ain't possible. (You can uppercase ASCII,
> UTF-16, or UTF-32 in place. But not UTF-8, and char[], by definition,
> is UTF-8).

What about inPlaceToUpperASCII(char[] str)?

in other words, yeah, toUpper can use a UTF-8 string, and return a UTF-8 
string, but I can see use in having a function that expects to receive ASCII 
and uppercases in-place.  The function would be a lot simpler in any case :)

-Steve 





More information about the Digitalmars-d mailing list