]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/codec.h
Refuse to encode invalid Unicode characters in UTF-8
[libs/core.git] / source / stringcodec / codec.h
index c70e052dd1b35e819a591327777f8eec4dbdc9bd..d0871ff119ab563ea2ff000ece006c55577ddf48 100644 (file)
@@ -41,7 +41,7 @@ public:
        protected:
                ErrorMode err_mode;
 
-               Encoder(ErrorMode em): err_mode(em) { }
+               Encoder(ErrorMode em): err_mode(em==DEFAULT ? THROW_ON_ERROR : em) { }
        public:
                virtual ~Encoder() { }
 
@@ -92,7 +92,7 @@ public:
        protected:
                ErrorMode err_mode;
 
-               Decoder(ErrorMode em): err_mode(em) { }
+               Decoder(ErrorMode em): err_mode(em==DEFAULT ? THROW_ON_ERROR : em) { }
        public:
                virtual ~Decoder() { }
 
@@ -177,7 +177,7 @@ public:
 
 
 /** Convenience function that decodes a string. */
-template<class C>
+template<typename C>
 ustring decode(const std::string &s)
 {
        typename C::Decoder dec;
@@ -185,7 +185,7 @@ ustring decode(const std::string &s)
 }
 
 /** Convenience function that encodes a string. */
-template<class C>
+template<typename C>
 std::string encode(const ustring &s)
 {
        typename C::Encoder enc;
@@ -193,7 +193,7 @@ std::string encode(const ustring &s)
 }
 
 /** Convenience function that transcodes a string from one codec to another. */
-template<class F, class T>
+template<typename F, typename T>
 std::string transcode(const std::string &s)
 {
        return encode<T>(decode<F>(s));