Refuse to encode invalid Unicode characters in UTF-8
authorMikko Rasa <tdb@tdb.fi>
Tue, 4 Sep 2012 06:46:19 +0000 (09:46 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 4 Sep 2012 06:46:19 +0000 (09:46 +0300)
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;