]> git.tdb.fi Git - libs/core.git/blob - source/latin1.cpp
More sophisticated error handling
[libs/core.git] / source / latin1.cpp
1 #include "latin1.h"
2
3 using namespace std;
4
5 namespace Msp {
6
7 void Latin1::Encoder::encode_char(wchar_t c_)
8 {
9         // Win32 has typedef unsigned short wchar_t
10         int c=c_;
11         if(c<0 || c>0xFF)
12                 error("Can't express character in Latin-1");
13         else
14                 append(c);
15 }
16
17 void Latin1::Decoder::decode_char(const string &str, string::const_iterator &i)
18 {
19         if(i==str.end())
20                 return;
21         append(static_cast<unsigned char>(*i++));
22 }
23
24 } // namespace Msp