std.string.toUpper() for greek characters

Minas minas_mina1990 at hotmail.co.uk
Wed Oct 3 07:11:07 PDT 2012


On Wednesday, 3 October 2012 at 13:27:25 UTC, Paulo Pinto 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.
>
> Regarding toLower() a problem I see is how to handle sigma 
> (Σ), because it has two possible lower case representations 
> depending where it occurs in a word. But of course toLower() is 
> working on character basis, so it cannot know what the receiver 
> plans to do with the character.
>
> --
> Paulo

Yeah, that's a problem indeed. I will make it become 'σ', and 
the programmer can change the final'σ' to 'ς' himself.


More information about the Digitalmars-d-announce mailing list