在Perl的來到,我可以這樣做以下測試在一個特定的Unicode塊字符串的成員:的Python和Unicode塊的正則表達式
# test if string has any katakana script characters
my $japanese = "カタカナ";
if ($japanese =~ /\p{InKatakana}/) {
print "string has katakana"
}
我讀過Python做不支持unicode塊(true?) - 那麼手動實現這一點的最佳方式是什麼?例如,{InKatakana}的上述unicode塊範圍應該是U + 30A0 ... U + 30FF。我如何在Python中測試unicode範圍?其他推薦的解決方案?
我不想用像Ponyguruma這樣的外部包裝來限制展開/維護的依賴關係的數量。
完美,謝謝。 – jbb 2010-06-30 13:04:38