Decoder *dec = create_decoder(IGNORE_ERRORS);
bool result = true;
- for(string::const_iterator i=str.begin(); (result && i!=str.end()); )
+ for(auto i=str.begin(); (result && i!=str.end()); )
result = (dec->decode_char(str, i)!=-1);
delete dec;
void Codec::Encoder::encode(const ustring &str, string &buf)
{
- for(ustring::const_iterator i=str.begin(); i!=str.end(); ++i)
- encode_char(*i, buf);
+ for(unichar c: str)
+ encode_char(c, buf);
}
string Codec::Encoder::encode(const ustring &str)
void Codec::Decoder::decode(const string &str, ustring &buf)
{
- for(string::const_iterator i=str.begin(); i!=str.end();)
+ for(auto i=str.begin(); i!=str.end();)
{
unichar c = decode_char(str, i);
if(c!=-1)
bool is_latin1 = true;
unsigned utf8_mb = 0;
- for(string::const_iterator i=str.begin(); i!=str.end(); ++i)
+ for(char c: str)
{
- unsigned char c = *i;
if(c&0x80)
{
is_ascii = false;