7 void Utf8::Encoder::encode_char(wchar_t c)
12 error("Can't express character in UTF-8");
30 buf[0]=0xFF<<(8-bytes) | code>>(bytes*6-6);
31 for(unsigned j=bytes-1; j>0; --j)
33 buf[j]=0x80 | code&0x3F;
42 void Utf8::Decoder::decode_char(const string &str, string::const_iterator &i)
50 error("Invalid UTF-8 string (tail byte when expecting head)");
57 for(; *i&mask; mask>>=1)
62 error("Invalid UTF-8 string (overlong multibyte sequence)");
71 error("Invalid UTF-8 string (denormalized multibyte sequence)");
86 error("Invalid UTF-8 string (head byte when expecting tail)");
91 code=code<<6 | (*i++)&0x3F;
97 error("Invalid UTF-8 string (character out of range)");
106 void Utf8::Decoder::sync()
110 error("Sync in the middle of multibyte UTF-8 sequence");
115 void Utf8::Decoder::reset()