]> git.tdb.fi Git - libs/core.git/blob - source/ascii.cpp
10eb7949b713d14e49d621b568cd205760a21aa7
[libs/core.git] / source / ascii.cpp
1 #include "ascii.h"
2
3 using namespace std;
4
5 namespace Msp {
6
7 void Ascii::Encoder::encode_char(wchar_t c)
8 {
9         if(c<0 || c>0x7F)
10                 throw CodecError("Can't express character in ASCII");
11         append(c);
12 }
13
14
15 void Ascii::Decoder::decode_char(const string &str, string::const_iterator &i)
16 {
17         if(i==str.end())
18                 return;
19         if(*i&0x80)
20                 throw CodecError("Invalid ASCII string (undefined character)");
21         append(*i++);
22 }
23
24 } // namespace Msp