]> git.tdb.fi Git - libs/core.git/blobdiff - source/iso88591.cpp
Rework the codec API completely to remove the internal buffering
[libs/core.git] / source / iso88591.cpp
index 73169c84ef6ace9888563be239564de998ec1052..17f84b1755311fde538e6b899f9823133f3d39af 100644 (file)
@@ -10,22 +10,29 @@ Distributed under the LGPL
 using namespace std;
 
 namespace Msp {
+namespace Codecs {
 
-void Iso88591::Encoder::encode_char(wchar_t c_)
+void Iso88591::Encoder::encode_char(UnicodeChar ch, string &buf)
 {
-       // Win32 has typedef unsigned short wchar_t
-       int c=c_;
-       if(c<0 || c>0xFF)
-               error("Can't express character in Latin-1");
-       else
-               append(c);
+       if(ch<0 || ch>0xFF)
+               return error(ch, buf, "Can't express character in ISO-8859-1");
+
+       buf+=ch;
+}
+
+void Iso88591::Encoder::transliterate(UnicodeChar, string &buf)
+{
+       buf+='?';
 }
 
-void Iso88591::Decoder::decode_char(const string &str, string::const_iterator &i)
+
+UnicodeChar Iso88591::Decoder::decode_char(const string &str, string::const_iterator &i)
 {
        if(i==str.end())
-               return;
-       append(static_cast<unsigned char>(*i++));
+               return error("No input");
+
+       return static_cast<unsigned char>(*i++);
 }
 
+} // namespace Codecs
 } // namespace Msp