X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Futf8.cpp;fp=source%2Fstringcodec%2Futf8.cpp;h=c6d1990d0b00e6ae36870e8b0af7978f09cdb9fa;hp=4c75d8b073e277c2adc2f38db5f3db806da7b0e5;hb=94ee3a1040f67d9de2e92fc34049642b08d65b3e;hpb=93bb92bad766d269a6bac87e00020a6158531739 diff --git a/source/stringcodec/utf8.cpp b/source/stringcodec/utf8.cpp index 4c75d8b..c6d1990 100644 --- a/source/stringcodec/utf8.cpp +++ b/source/stringcodec/utf8.cpp @@ -8,7 +8,7 @@ namespace StringCodec { void Utf8::Encoder::encode_char(unichar ch, string &buf) { if(ch<0 || ch>0x10FFFF) - return error(ch, buf, "Can't express character in UTF-8"); + return error(ch, buf, invalid_character(ch, "UTF-8")); unsigned bytes = 1; if(ch>0xFFFF) @@ -48,7 +48,7 @@ unichar Utf8::Decoder::decode_char(const string &str, string::const_iterator &i) if((*i&0xC0)==0x80) { - unichar result = error("UTF-8 tail byte found when expecting head"); + unichar result = error(invalid_sequence(i, i+1, "stray UTF-8 head byte")); ++i; return result; } @@ -68,11 +68,11 @@ unichar Utf8::Decoder::decode_char(const string &str, string::const_iterator &i) result = (result<<6) | ((*j++)&0x3F); if(k>(bytes*5-4)) || !(result>>7)) - result = error("Denormalized UTF-8 multibyte sequence"); + result = error(invalid_sequence(i, j, "denormalized UTF-8 sequence")); else if(!is_valid_unichar(result)) - result = error("Invalid Unicode code point"); + result = error(invalid_sequence(i, j, "undefined UTF-8 character")); i = j; return result;