如何在不将非法输入替换为替换字符的情况下解码 UTF-8?
How to decode UTF-8 without having illegal input replaced by a replacement character?
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.
If the input string is not well-formed, then the U_INVALID_CHAR_FOUND
error code is set
http://icu-project.org/apiref/icu4c/ustring_8h.html#a5f9ff224b11166a106d1b3ac26454cd4
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.
If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set
http://icu-project.org/apiref/icu4c/ustring_8h.html#a5f9ff224b11166a106d1b3ac26454cd4