std.string.toUpper() for greek characters

Minas minas_mina1990 at hotmail.co.uk
Wed Oct 3 03:56:20 PDT 2012


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.


More information about the Digitalmars-d-announce mailing list