X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstringcodec%2Fcodec.cpp;h=3dc4f9a9d452efe7aef2478878d36ad3977af170;hb=93bb92bad766d269a6bac87e00020a6158531739;hp=b7c600d74d6fbf0c70ccfd5fed9b766bd96a1c56;hpb=02794ef3620d0d9cc3b8f1c0d8f2995c825fdf4f;p=libs%2Fcore.git diff --git a/source/stringcodec/codec.cpp b/source/stringcodec/codec.cpp index b7c600d..3dc4f9a 100644 --- a/source/stringcodec/codec.cpp +++ b/source/stringcodec/codec.cpp @@ -16,17 +16,11 @@ namespace StringCodec { bool Codec::detect(const string &str) const { - Decoder *dec = create_decoder(); + Decoder *dec = create_decoder(IGNORE_ERRORS); + bool result = true; - try - { - for(string::const_iterator i=str.begin(); i!=str.end(); ) - dec->decode_char(str, i); - } - catch(const CodecError &) - { - result = false; - } + for(string::const_iterator i=str.begin(); (result && i!=str.end()); ) + result = (dec->decode_char(str, i)!=-1); delete dec; @@ -83,7 +77,7 @@ unichar Codec::Decoder::error(const string &msg) switch(err_mode) { case TRANSLITERATE: - return 0xFFFE; + return 0xFFFD; case IGNORE_ERRORS: return -1; default: