void JisX0208::Encoder::encode_char(wchar_t ucs)
{
unsigned short jis=ucs_to_jisx0208(ucs);
- if(!jis) throw CodecError("Can't express character in JIS X 0208");
-
- char buf[2]={jis>>8, jis};
- append(buf, 2);
+ if(jis)
+ {
+ char buf[2]={jis>>8, jis};
+ append(buf, 2);
+ }
+ else
+ error("Can't express character in JIS X 0208");
}
wchar_t ucs=jisx0208_to_ucs(high<<8 | *i++);
high=0;
- if(!ucs)
- throw CodecError("Invalid JIS X 0208 string (undefined character)");
-
- append(ucs);
+ if(ucs)
+ append(ucs);
+ else
+ error("Invalid JIS X 0208 string (undefined character)");
}
void JisX0208::Decoder::sync()
{
if(high)
- throw CodecError("Sync in middle of JIS X 0208 character");
-}
-
-void JisX0208::Decoder::reset()
-{
- high=0;
+ {
+ error("Sync in middle of JIS X 0208 character");
+ high=0;
+ }
}
wchar_t jisx0208_to_ucs(unsigned short jis)