std.stringbuffer
Spacen Jasset
spacenjasset at yahoo.co.uk
Thu May 1 06:19:30 PDT 2008
Janice Caron wrote:
> 2008/4/30 Me Here <p9e883002 at sneakemail.com>:
>> 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).
I think uppercasing non ascii (english) characters is a more of
specialised business anyway (some languages have no notion of upper
case, and yet others depend on context), which often should be perfomed
by a presentation layer.
People need a toupper/lower all the time, and 90% of the time they use
it on strings that are in the ascii range, often because they deal with
protocols, file formats and other such things.
In which case phobos's string.toupper shouldn't really be doing work
outside of ascii, in my opinion anyway. This also means that a string
can be uppercased in place.
More information about the Digitalmars-d
mailing list