Get all uppercase letters of the current culture

I know that there is CultureInfo.TextInfo.ToUpper(), however, is there a way to get a collection of all the capital letters for a given culture?

Please note that I want to get only the uppercase letters of the current alphabet. For instance. for en-USI want to get a list A,B,C,...Y,Z(the order doesn't actually matter).

+4
source share
3 answers

There is no built-in database in .NET that tracks letters that appear in the alphabet of a particular language. It will be very big. And controversial, even a country with a simple alphabet like the Netherlands has speakers who disagree with the fact that Ÿ the digraph is in the alphabet or not, and in what position it appears. The former Yugoslavia had two alphabets; wars were fought against it. And volatile, the Swedish recently added W, forced into the World Wide Web. And quite impractical for languages ​​like Chinese and Korean.

You do not want this problem to be solved in the general case.

+2
source

Depending on your actual definition of capital letters, many of them are in invariant culture, not to mention others, and vary depending on your operating system.

LinqPad 973 ( Win8.1, 873 Vista, 673 XP) , char, ToUpperInvariant ToLowerInvariant:

var UppercaseChars = from i in Enumerable.Range(0, 65536)
                    let c = (char)i
                    let u = Char.ToUpperInvariant(c)
                    let l = Char.ToLowerInvariant(c)
                    where c == u && u != l
                    select c;
UppercaseChars.Count().Dump();
String.Join(" ", UppercaseChars).Dump();

LinqPad

, , CultureInfo.TextInfo.ToUpper .ToLower, .

, "" 33 ( Win8.1, 135 Vista, 306 XP), Unicode, ( ToLowerInvariant). , 69 ( Win8.1, 71 Vista, 42 XP), UppercaseLetter Unicode, ( ToLowerInvariant). - Unicode TitlecaseLetter ( XP), LetterNumber OtherSymbol. Vista 4 Unicode LowercaseLetter (ῃ ῳ ⱥ ⱦ).

+1

: - Char.GetUnicodeCategory. - .

255 ; .

, Unicode, .

0

Source: https://habr.com/ru/post/1532640/


All Articles