我有前進1 UTF-8字符和返回的字節數花了到那裏的函數:函數返回1個UTF-8字符?
// Moves the iterator to next unicode character in the string,
//returns number of bytes skipped
template<typename _Iterator1, typename _Iterator2>
inline size_t bringToNextUnichar(_Iterator1& it,
const _Iterator2& last) const {
if(it == last) return 0;
unsigned char c;
size_t res = 1;
for(++it; last != it; ++it, ++res) {
c = *it;
if(!(c&0x80) || ((c&0xC0) == 0xC0)) break;
}
return res;
}
我怎麼能修改,這樣我可以從任意回去Unicode字符字符?
謝謝
Utf8可能需要超過1個字符。 – 2011-02-11 01:33:30