我有一个函数,它前进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;
}
Run Code Online (Sandbox Code Playgroud)
我怎么能修改这个,以便我可以从任意字符返回一个unicode字符?
谢谢
| 归档时间: |
|
| 查看次数: |
321 次 |
| 最近记录: |