X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstringcodec%2Fcodec.h;h=5acbe7b0d1dc34b1d7285c6b96a63665b1ffde2f;hb=9a79b9ca04d934e8e5b865a1d2b6719f76ec9d15;hp=a307e2ec8acc3a784d1f57ce9d7ca4516dfff4fc;hpb=b011b17393069d86790b2291a759280e15c75a0f;p=libs%2Fcore.git diff --git a/source/stringcodec/codec.h b/source/stringcodec/codec.h index a307e2e..5acbe7b 100644 --- a/source/stringcodec/codec.h +++ b/source/stringcodec/codec.h @@ -3,14 +3,11 @@ #include #include +#include "ustring.h" namespace Msp { namespace StringCodec { -typedef int UnicodeChar; - -typedef std::basic_string ustring; - enum ErrorMode { THROW_ON_ERROR, @@ -58,7 +55,7 @@ public: /** Encodes a single unicode character. If the character can't be represented in this encoding, error() should be called. */ - virtual void encode_char(UnicodeChar ch, std::string &buf) = 0; + virtual void encode_char(unichar ch, std::string &buf) = 0; /** Encodes a unicode string. This is equivalent to calling encode_char for each character in the string with the same buffer. */ @@ -79,11 +76,11 @@ public: THROW_ON_ERROR: throws CodecError(msg) IGNORE_ERRORS: does nothing TRANSLITERATE: calls transliterate(ch, buf) */ - void error(UnicodeChar ch, std::string &buf, const std::string &msg); + void error(unichar ch, std::string &buf, const std::string &msg); /** Attempts to produce an alternative encoding for a unicode character. Typically this includes dropping accent marks or romanizing letters. */ - virtual void transliterate(UnicodeChar ch, std::string &buf) = 0; + virtual void transliterate(unichar ch, std::string &buf) = 0; }; /** @@ -105,7 +102,7 @@ public: state change sequence was decoded but no character followed it. If invalid input is encountered, the error() function should be called and the iterator advanced only if it doesn't throw. */ - virtual UnicodeChar decode_char(const std::string &str, std::string::const_iterator &i) = 0; + virtual unichar decode_char(const std::string &str, std::string::const_iterator &i) = 0; /** Decodes a string. */ virtual void decode(const std::string &str, ustring &buf); @@ -121,8 +118,8 @@ public: THROW_ON_ERROR: throws CodecError(msg) IGNORE_ERRORS: returns -1 - TRANSLITERATE: return 0xFFFE */ - UnicodeChar error(const std::string &msg); + TRANSLITERATE: return 0xFFFD */ + unichar error(const std::string &msg); }; protected: