]> git.tdb.fi Git - libs/core.git/blob - source/iso88591.cpp
73169c84ef6ace9888563be239564de998ec1052
[libs/core.git] / source / iso88591.cpp
1 /* $Id$
2
3 This file is part of libmspstrings
4 Copyright © 2006-2007 Mikko Rasa
5 Distributed under the LGPL
6 */
7
8 #include "iso88591.h"
9
10 using namespace std;
11
12 namespace Msp {
13
14 void Iso88591::Encoder::encode_char(wchar_t c_)
15 {
16         // Win32 has typedef unsigned short wchar_t
17         int c=c_;
18         if(c<0 || c>0xFF)
19                 error("Can't express character in Latin-1");
20         else
21                 append(c);
22 }
23
24 void Iso88591::Decoder::decode_char(const string &str, string::const_iterator &i)
25 {
26         if(i==str.end())
27                 return;
28         append(static_cast<unsigned char>(*i++));
29 }
30
31 } // namespace Msp