-/**
-Creates a codec for the given encoding. The caller is responsible for deleting
-the codec when it's no longer needed.
-*/
-StringCodec *create_codec(const string &n)
+void Codec::Encoder::encode(const ustring &str, string &buf)
+{
+ for(ustring::const_iterator i=str.begin(); i!=str.end(); ++i)
+ encode_char(*i, buf);
+}
+
+void Codec::Encoder::error(UnicodeChar ch, string &buf, const string &msg)
+{
+ switch(err_mode)
+ {
+ case TRANSLITERATE:
+ transliterate(ch, buf);
+ case IGNORE_ERRORS:
+ break;
+ default:
+ throw CodecError(msg);
+ }
+}
+
+
+void Codec::Decoder::decode(const string &str, ustring &buf)
+{
+ for(string::const_iterator i=str.begin(); i!=str.end();)
+ {
+ UnicodeChar c=decode_char(str, i);
+ if(c!=-1)
+ buf+=c;
+ }
+}
+
+UnicodeChar Codec::Decoder::error(const string &msg)
+{
+ switch(err_mode)
+ {
+ case TRANSLITERATE:
+ return 0xFFFE;
+ case IGNORE_ERRORS:
+ return -1;
+ default:
+ throw CodecError(msg);
+ }
+}
+
+Codec *create_codec(const string &n)