如何转换成韩文缩写 [英] How to convert to Korean initials

查看:89
本文介绍了如何转换成韩文缩写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用韩国的Android应用程序。

Hi Im working on a Korean android app.

在这里,我实现了一个带有字母部分标题的列表视图来显示联系人。我使用String类的substring方法获取第一个字母作为节标题。对于韩国人,我也使用子字符串方法获取首字母。在这里,我需要将韩语首字母显示为Korean contactㄷㄹㅎㅎㅍㅍㅎ。我真的不知道韩国联系人列表中的哪个首字母与这些韩国首字母匹配。

Here I implemented a listview with alphabetic section headers to display contacts. I used substring method of String class to get the first letter as section header. For korean contacts also im taking first letter using substring method. Here I need to display Korean initials as ㄱ ㄴ ㄷ ㄹ ㅁ ㅂ ㅅ ㅇ ㅈ ㅊ ㅋ ㅌ ㅍ ㅎ with respects to first letter of the Korean contact. I'm not really know which first letter of the Korean contact list matches with these Korean initials.

所以请帮助我如何做或给我参考以遵循...

So please help me how i can do this or give me reference to follow...

在此先感谢。

推荐答案

我不知道在韩国应用中,仅凭一个惯用的字符就具有智能感知是不正常的行为-似乎通常是使用完整的Jamo来完成的。但是,我认为没有理由不应该这样做-那就让我们这样做。

I don't think it is normal behaviour in a Korean app to have intellisense from just an intial character - it seems to usually be done with a full Jamo. However, I see no reason why you shouldn't do it - so lets do it.

首先,您错过了双缩写。这些与单打不同,因为它们确实需要不同的按键(通常是shift +字符)。无论如何,您的姓名缩写列表应为:

Firstly, you missed the double initials. These are different from the singles, as they do require a different key press (usually shift+character). Anyhow, your list of initials should be:

ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ

键入首字母时,您要做的第一件事就是获取以该首字母开头的字符范围。

The first thing you need to do when an initial is typed in is to get the range of characters that start with that particular initial.

通过查看Windows字符映射,我可以看到第一个字母Ka(가)在Unicode点 0xAC00 (或十进制, 44032 ),因此要获取任何范围,都必须将此值添加到我们进行的任何计算中。因此,您应该有一个名为 FirstLetter 的常数,或它的值应为 44032

By looking at the Windows Character Map, I one can see that the first letter, Ka (가) is at Unicode point 0xAC00 (or decimal, 44032), so to get any range, this value will have to be added to any calculation we do. So you should have a constant called FirstLetter or whatever, and its value should be 44032.

까是 0xAE4C (或十进制 44620 ),因此我们现在有一个乘数(即,以任何特定首字母开头的字符数-所有首字母均相同,因此为 44620-44032 588

까 is at 0xAE4C (or decimal 44620), so we now have a multiplier (i.e. the number of characters beginning with any particular initial - which is the same for all initials, so that is 44620-44032 which is 588.

我们现在有足够的信息来实现您的智能感知。如果您在数组中具有首字母缩写,我们可以使用键入字符的索引

We now have enough information to implement your intellisense. If you have the initialisms in an array, we can use the index of the typed character in that array to find the range of characters that start with it.

因此,如果我们以start开头,显然我们希望将所有内容从가返回到깋。全部588个ㄱ给我们一个'0',所以我们有

So if we start with ㄱ, we obviously want to return everything from 가 to 깋. All 588 of them. So ㄱ gives us a '0', so we have

startCodePoint = index * 588 + 44032
// = 0 * 588 + 44032 == 44032 == 가
endCodePoint = (index + 1) * 588 + 44032
// this will include 까

然后您就可以必须通过检查

And then you can just check that a particular character starts with 'ㄱ' by checking

if(charcode >= startCodePoint && charcode < endCodePoint) { ... }

其中字符代码是您的智能感知列表中某个项的第一个字符。

where charcode is the first character of one of the items in your intellisense list.

使用类似的方法来查找如何检查字符是否以가开头。一切都以Unicode顺序进行,所以这是一个非常简单的任务。

Use a similar methodology to find out how to check that a character starts with say '가'. Everything is in order in Unicode, so this is a very simple task.

要获取任何字符的首字母,您可以反过来使用上述公式。

To get the initial letter of any character, you can use the above formula in reverse.

ie


  1. 获取unicode第一个字符的值(例如각)

  2. 从该值中减去44032。

  3. 将该值除以588。

  4. 使用该值作为索引以从缩写列表中检索初始字符。

  1. Get the unicode value of the first character (e.g. 각)
  2. Subtract 44032 from this value.
  3. Divide this value by 588.
  4. Use that value as the index to retrieve the intial character from the list of initials.

例如

String initials = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ";
int value = character.codePointAt(0);
value = (value - 44032) / 588;
String initial = initials.substring(value, 1);

这篇关于如何转换成韩文缩写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆