std.string.toUpper() for greek characters
Minas
minas_mina1990 at hotmail.co.uk
Wed Oct 3 04:08:13 PDT 2012
On Wednesday, 3 October 2012 at 11:03:27 UTC, Jakob Ovrum wrote:
> On Wednesday, 3 October 2012 at 10:56:11 UTC, Minas wrote:
>> Currently, toUpper() (and probably toLower()) does not handle
>> greek characters correctly. I fixed toUpper() by making a
>> another function for greek characters
>>
>> // called if (c >= 0x387 && c <= 0x3CE)
>> dchar toUpperGreek(dchar c)
>> {
>> if( c >= 'α' && c <= 'ω' )
>> {
>> if( c == 'ς' )
>> c = 'Σ';
>> else
>> c -= 32;
>> }
>> else
>> {
>> dchar[dchar] map;
>> map['ά'] = 'Ά';
>> map['έ'] = 'Έ';
>> map['ή'] = 'Ή';
>> map['ί'] = 'Ί';
>> map['ϊ'] = 'Ϊ';
>> map['ΐ'] = 'Ϊ';
>> map['ό'] = 'Ό';
>> map['ύ'] = 'Ύ';
>> map['ϋ'] = 'Ϋ';
>> map['ΰ'] = 'Ϋ';
>> map['ώ'] = 'Ώ';
>>
>> c = map[c];
>> }
>>
>> return c;
>> }
>>
>> Then, in toUpper()
>> {
>> ....
>> if (c >= 0x387 && c <= 0x3CE)
>> c = toUpperGreek()...
>> ///
>> }
>>
>> Do you think it should stay like that or I should copy-paste
>> it in the body of toUpper()?
>>
>> I'm going to fix toLower() as well and make a pull request.
>
> A switch with 11 cases is very likely going to be a lot faster
> than the hash table approach you're using, especially since the
> AA is not cached and will be dynamically allocated on every
> call.
I had this in mind as well. I will change it, thanks.
More information about the Digitalmars-d-announce
mailing list