How to group Japanese and other non-Latin names in LongListSelector?

If you put your Windows Phone emulator or device in Japanese, Korean, or other non-Latin languages ​​and use the application for people, their LongListSelector implementation displays Japanese grouping characters, and then the Unicode Meridian Globe followed by az characters:

WP7 People AppWP7 People App

Using LongListSelector from the Windows Phone toolkit, you need to execute your own grouping logic manually. How to get a list of characters of a Japanese / Korean / named group of names and how to determine which grouping symbol named the name (because, looking at my second screenshot, the grouping symbol is nowhere in the username)?

+8
c # windows-phone-7 internationalization longlistselector
source share
2 answers

Short answer: you add 96 to the unicode value of hiragana (ま) to get the equivalent katakana (γƒž).

You can determine if the character is a hiragana by checking that the unicode value falls in the range 3040-309F.

Unfortunately, as Noah mentions, many names are written using kanji: an alphabet of about 40,000 characters each with hiragana equivalents and many contextual ones for their surroundings. If you want to support them, you will need to find a Japanese language library that will help you.

FYI, katakana is sometimes used to represent capital letters to explain their use here. (Given the preferences of the lower case Metro, I would think that a katakana is better suited)

If you only want to support hiragana, here is something that should help:

const int KatakanaStartCode = 0x30A0; const int HiraganaStartCode = 0x3040; const int HiraganaEndCode = 0x309F; private char GetGroupChar(string name) { // Check for null/blank // Check for numbers, etc char firstChar = name[0]; int firstCharCode = (int)firstChar; bool isHiragana = (HiraganaStartCode <= firstCharCode && firstCharCode <= HiraganaEndCode); if (isHiragana) { char katakanaChar = (char)(firstCharCode + (KatakanaStartCode - HiraganaStartCode)); return katakanaChar; } return Char.ToLowerInvariant(firstChar); } 

And then:

 string name = "またγͺ たγͺかあ"; char s = GetGroupChar(name); Debug.WriteLine(s); // γƒž 
+3
source share

I don't know anything about the Windows Phone Toolkit in particular, but basically, it works as follows: most Japanese names will be in the form of kanji (usually how it is written and what is displayed). Since the Kanji form can have an ambiguous pronunciation, there are also fields for pronunciation. You use the pronunciation field to group names. (And you can group any names without data in the pronunciation field into another β€œother” group).

For example: Kanji: ε±± 本 ζ¬‘ιƒŽ Katakana: ダ γƒž γƒ’ γƒˆ γ‚Έ γƒ­ ウ

Then your "grouping characters" are just a list (or partial list) of Katakana or Hiragana, and this guy will fall under "γ‚„" or "ダ".

+2
source share

All Articles