Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly uppercase Greek words in .NET?

We have ASP.NET application which runs different clients around the world. In this application we have dictionary for each language. In dictionary we have words in lowercase and sometimes we uppercase it in code for typographic reasons.

var greek= new CultureInfo("el-GR");
string grrr = "Πόλη";
string GRRR = grrr.ToUpper(greek); // "ΠΌΛΗ"

The problem is:

...if you're using capital letters then they must appear like this: f.e. ΠΟΛΗ and not like ΠΌΛΗ, same for all other words written in capital letters

So is it possible generically to uppercase Greek words correctly in .NET? Or should I wrote my own custom algorithm for Greek uppercase?

How do they solve this problem in Greece?

like image 285
Jakub Šturc Avatar asked Jan 07 '10 13:01

Jakub Šturc


3 Answers

I suspect that you're going to have to write your own method, if el-GR doesn't do what you want. Don't think you need to go to the full length of creating a custom CultureInfo, if this is all you need. Which is good, because that looks quite fiddly.

What I do suggest you do is read this Michael Kaplan blog post and anything else relevant you can find by him - he's been working on and writing about i18n and language issues for years and years and his commentary is my first point of call for any such issues on Windows.

like image 168
AakashM Avatar answered Oct 13 '22 06:10

AakashM


I don't know much about ASP.Net but I know how I'd do this in Java.

If the characters are Unicode, I would just post-process the output from ToUpper with some simple substitutions, one being the conversion of \u038C (Ό) to \u039F (Ο) or \u0386 (Ά) to \u0391 (Α).

From the looks of the Greek/Coptic code page (\u0370 through \u03ff), there's only a few characters (6 or 7) you'll need to change.

like image 45
paxdiablo Avatar answered Oct 13 '22 04:10

paxdiablo


Check out How do I remove diacritics (accents) from a string in .NET?

like image 42
Eduardo Molteni Avatar answered Oct 13 '22 04:10

Eduardo Molteni