Fix UTF-8 detection in Codecs::detect_codec
encode_char(*i, buf);
}
+string Codec::Encoder::encode(const ustring &str)
+{
+ string buf;
+ encode(str, buf);
+ sync(buf);
+ return buf;
+}
+
void Codec::Encoder::error(UnicodeChar ch, string &buf, const string &msg)
{
switch(err_mode)
}
}
+ustring Codec::Decoder::decode(const string &str)
+{
+ ustring buf;
+ decode(str, buf);
+ return buf;
+}
+
UnicodeChar Codec::Decoder::error(const string &msg)
{
switch(err_mode)
else if((c&0xC0)==0xC0)
{
if(utf8_mb)
+ {
is_utf8=false;
+ utf8_mb=0;
+ }
else
{
for(utf8_mb=1; (c>>(6-utf8_mb))&1; ++utf8_mb) ;
}
}
}
+ else if(utf8_mb)
+ {
+ is_utf8=false;
+ utf8_mb=0;
+ }
}
if(is_ascii)
*/
virtual void encode(const ustring &str, std::string &buf);
+ std::string encode(const ustring &);
+
/**
Procuces a sequence of bytes that will bring the encoder back to the
initial state.
*/
virtual void decode(const std::string &str, ustring &buf);
+ ustring decode(const std::string &);
+
/**
Resets the decoder to the initial state.
*/