]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/iso88591.cpp
Move files around to prepare for assimilation into core
[libs/core.git] / source / stringcodec / iso88591.cpp
diff --git a/source/stringcodec/iso88591.cpp b/source/stringcodec/iso88591.cpp
new file mode 100644 (file)
index 0000000..064d4a7
--- /dev/null
@@ -0,0 +1,38 @@
+/* $Id$
+
+This file is part of libmspstrings
+Copyright © 2006-2007 Mikko Rasa
+Distributed under the LGPL
+*/
+
+#include "iso88591.h"
+
+using namespace std;
+
+namespace Msp {
+namespace Codecs {
+
+void Iso88591::Encoder::encode_char(UnicodeChar ch, string &buf)
+{
+       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 += '?';
+}
+
+
+UnicodeChar Iso88591::Decoder::decode_char(const string &str, string::const_iterator &i)
+{
+       if(i==str.end())
+               return error("No input");
+
+       return static_cast<unsigned char>(*i++);
+}
+
+} // namespace Codecs
+} // namespace Msp