2

How can i detect that ToUpper() function is possible on this string ? By example when the language of input don't have a upper case. I have this :

String text = "لان يقوم غينيا انتصا";

Console.WriteLine(text.ToUpper(CultureInfo.CurrentUICulture));

and the output is : "???? ????? ????"

I tried this Console.WriteLine(text.ToUpper(new CultureInfo("ar"))); but the result is the same as previously.

Neyoh
  • 623
  • 1
  • 11
  • 33
  • 1
    does `Console.WriteLine(text)` print the characters? I thought ToUpper ignored unmapped chars. In other words, perhaps your console window doesn't have the font or locale to correctly display that string – payo May 16 '16 at 19:53
  • 1
    It's not the `ToUpper()` that's causing the problem. [See here for more info.](http://stackoverflow.com/questions/21751827/displaying-arabic-characters-in-c-sharp-console-application) – Matthew Watson May 16 '16 at 19:57
  • When I run this in LinqPad, it works as expected. – Cam Bruce May 16 '16 at 19:59
  • @CamBruce Try it in a console app; it won't work. – Matthew Watson May 16 '16 at 20:00
  • I tried on dotnetfiddle.net and it works :) – Neyoh May 16 '16 at 20:03
  • @Neyoh Do you really have to have this working in a console? You'll be in a world of pain, because the console doesn't support right-to-left languages! – Matthew Watson May 16 '16 at 20:06
  • To prove that `.ToUpper()` is not the problem, just doing `Console.WriteLine(text);` fails in the exact same way. – Scott Chamberlain May 16 '16 at 20:42

1 Answers1

0

Everything is right, exept for your text. The console can only print ASCII chars. A table of all chars you can use: http://www.asciitable.com/index/asciifull.gif This is because the font that the console use. If you change the incompatible font to a compatible, it will work.