【发布时间】:2015-06-10 17:10:06
【问题描述】:
icu::UnicodeString::fromUTF8 将非法输入替换为 U+FFFD。有没有办法检测它是否已经这样做了,以便我可以抛出异常?
【问题讨论】:
icu::UnicodeString::fromUTF8 将非法输入替换为 U+FFFD。有没有办法检测它是否已经这样做了,以便我可以抛出异常?
【问题讨论】:
使用 u_strFromUTF8
UChar* u_strFromUTF8 ( UChar * dest,
int32_t destCapacity,
int32_t * pDestLength,
const char * src,
int32_t srcLength,
UErrorCode * pErrorCode
)
Convert a UTF-8 string to UTF-16.
如果输入字符串格式不正确,则 U_INVALID_CHAR_FOUND 错误码已设置
http://icu-project.org/apiref/icu4c/ustring_8h.html#a5f9ff224b11166a106d1b3ac26454cd4
【讨论】: