如何在Perl或任何其他编程语言中对CJK(亚洲)字符进行排序?
发布时间:2020-12-15 21:16:46 所属栏目:大数据 来源:网络整理
导读:你如何在Perl中对中文,日文和韩文(CJK)字符进行排序? 据我所知,按行程计数排序CJK字符,然后按激进排序,似乎是这些语言的排序方式.还有一些按声音排序的方法,但这似乎不太常见. 我尝试过使用: perl -e 'print join(" ",sort qw(工 然 一 人 三 古 二 )),"n
你如何在Perl中对中文,日文和韩文(CJK)字符进行排序?
据我所知,按行程计数排序CJK字符,然后按激进排序,似乎是这些语言的排序方式.还有一些按声音排序的方法,但这似乎不太常见. 我尝试过使用: perl -e 'print join(" ",sort qw(工 然 一 人 三 古 二 )),"n";' # Prints: 一 三 二 人 古 工 然 which is incorrect 我尝试过使用CPAN的Unicode :: Collat??e,但它说:
如果我能得到每个字符的笔画计数数据库,我可以很容易地对所有字符进行排序,但这似乎不是Perl所带来的,也不是封装在我能找到的任何模块中. 如果你知道如何用其他语言对CJK进行排序,那么在这个问题的答案中提及它会很有帮助. 解决方法
有关脏细节和拐角情况,请参阅
TR38.它并不像您想象的那么容易,而且这个代码示例看起来像.
use 5.010; use utf8; use Encode; use Unicode::Unihan; my $u = Unicode::Unihan->new; say encode_utf8 sprintf "Character $_ has the radical #%s and %d residual strokes.",split /[.]/,$u->RSUnicode($_) for qw(工 然 一 人 三 古 二); __END__ Character 工 has the radical #48 and 0 residual strokes. Character 然 has the radical #86 and 8 residual strokes. Character 一 has the radical #1 and 0 residual strokes. Character 人 has the radical #9 and 0 residual strokes. Character 三 has the radical #1 and 2 residual strokes. Character 古 has the radical #30 and 2 residual strokes. Character 二 has the radical #7 and 0 residual strokes. 有关从根序数到笔画数的映射,请参阅http://en.wikipedia.org/wiki/List_of_Kangxi_radicals. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |