Refuse to encode invalid Unicode characters in UTF-8
[libs/core.git] / source / stringcodec / utf8.cpp
index c6d1990d0b00e6ae36870e8b0af7978f09cdb9fa..b75b39780edfa6269ad09fa780ca9a565f574872 100644 (file)
@@ -7,7 +7,7 @@ namespace StringCodec {
 
 void Utf8::Encoder::encode_char(unichar ch, string &buf)
 {
-       if(ch<0 || ch>0x10FFFF)
+       if(!is_valid_unichar(ch))
                return error(ch, buf, invalid_character(ch, "UTF-8"));
 
        unsigned bytes = 1;