views:

146

answers:

3

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?

+4  A: 

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.

AakashM
+2  A: 

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.

paxdiablo
That's evil. What if the customer one day inputs such a character willingly?
Maximilian Mayerl
It's already been stated in the comments that uppercase Greek words never have diacritics except for the word Ἢ: "When a word is written entirely in capital letters, diacritics are never used; the word Ἢ ("or") is an exception to this rule" (see http://www.statemaster.com/encyclopedia/Diacritics-%28Greek-alphabet%29)
paxdiablo
So? I, as the customer, want the program not to change the uppercase I have already written myself, even if it contains such a diacritic. It's up to me what I want to save in a text field, and if your program changes my explicitly written text, I'm going to persuade your support department until they run crying out of the company building. ;) Well, maybe a little exeggerated, but my point is that that would be a quick and dirty solution which sould never be in a production system.
Maximilian Mayerl
@MM, I understand that, but you're *not* the customer, Jakub is, and he has stated that they must appear that way. If you want to ask a *different* question, do so by all means.
paxdiablo