X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Fcodec.cpp;fp=source%2Fstringcodec%2Fcodec.cpp;h=abec134b1a0fd00a25f936952368beba22c62742;hp=21ddf8a7307ff8071551f4eb0473dfff48f05898;hb=f24e7b96e76b63c9b9b8a6bce4c7a9db64276ea8;hpb=9f754b788b872f9768af8c3a4f9e001a588e011a diff --git a/source/stringcodec/codec.cpp b/source/stringcodec/codec.cpp index 21ddf8a..abec134 100644 --- a/source/stringcodec/codec.cpp +++ b/source/stringcodec/codec.cpp @@ -20,7 +20,7 @@ bool Codec::detect(const string &str) const 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; @@ -30,8 +30,8 @@ bool Codec::detect(const string &str) const 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) @@ -46,7 +46,7 @@ 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) @@ -111,9 +111,8 @@ Codec *detect_codec(const string &str) 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;