我注意到BreakIterator的语言环境“en_Us”和“ja_JP”表现不同,即使文档说两个中断规则现在都相同。我错了吗?
“りんご是一个水果”是我用过的测试用例。这打破了“en_US”语言环境中日语脚本的每个字符,但在“ja_JP”语言环境中按预期工作。如果我使用“ja_JP”它是否适用于所有其他语言?我应该使用什么来支持多语言。
UErrorCode status = U_ZERO_ERROR;
UText *ut = utext_openUTF8(NULL, gUTF8Str, -1, &status);
BreakIterator* boundary = BreakIterator::createWordInstance("ja_JP", status);
boundary->setText(ut, status);
int pos_1 = ubrk_first(&bi);
int pos_2 = ubrk_next(&bi);
while (pos_2 != -1) {
//printf text
pos_1 = pos_2;
pos_2 = ubrk_next(&bi);
}
我正在使用ICU 4.8。