如何在Perl或任何其他编程语言中对CJK(亚洲)字符进行排序?

Nei*_*eil 10 sorting unicode perl collation cjk

你如何在Perl中对中文,日文和韩文(CJK)字符进行排序?

据我所知,按行程计数排序CJK字符,然后按激进排序,似乎就是这些语言的排序方式.还有一些按声音排序的方法,但这似乎不太常见.

我尝试过使用:

perl -e 'print join(" ", sort qw(? ? ? ? ? ? ? )), "\n";'
# Prints: ? ? ? ? ? ? ? which is incorrect
Run Code Online (Sandbox Code Playgroud)

我尝试过使用CPAN中的Unicode :: Collat​​e,但它说:

默认情况下,CJK Unified Ideographs按Unicode代码点顺序排序...

如果我能得到每个字符的笔画数量数据库,我可以轻松地对所有字符进行排序,但这似乎不是Perl所带来的,也不是封装在我能找到的任何模块中.

如果你知道如何用其他语言对CJK进行排序,那么在这个问题的答案中提及它会很有帮助.

dax*_*xim 4

有关肮脏的细节和极端情况,请参阅TR38 。它并不像您想象的那么简单,也不像此代码示例那样简单。

\n\n
use 5.010;\nuse utf8;\nuse Encode;\nuse Unicode::Unihan;\nmy $u = Unicode::Unihan->new;\n\nsay encode_utf8 sprintf "Character $_ has the radical #%s and %d residual strokes." , split /[.]/, $u->RSUnicode($_) for qw(\xe5\xb7\xa5 \xe7\x84\xb6 \xe4\xb8\x80 \xe4\xba\xba \xe4\xb8\x89 \xe5\x8f\xa4 \xe4\xba\x8c);\n__END__\nCharacter \xe5\xb7\xa5 has the radical #48 and 0 residual strokes.\nCharacter \xe7\x84\xb6 has the radical #86 and 8 residual strokes.\nCharacter \xe4\xb8\x80 has the radical #1 and 0 residual strokes.\nCharacter \xe4\xba\xba has the radical #9 and 0 residual strokes.\nCharacter \xe4\xb8\x89 has the radical #1 and 2 residual strokes.\nCharacter \xe5\x8f\xa4 has the radical #30 and 2 residual strokes.\nCharacter \xe4\xba\x8c has the radical #7 and 0 residual strokes.\n
Run Code Online (Sandbox Code Playgroud)\n\n

请参阅http://en.wikipedia.org/wiki/List_of_Kangxi_radicals了解从部首序数到笔画数的映射。

\n