X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fjisx0208.cpp;h=1e5aec7db0bbafb63f06c55c961e5b2648acb69f;hb=3ab2746e9f0626d691d8946d50ed399d45e9f770;hp=4d46f709f89df5f739aa7c11a6a298505f41ed45;hpb=51b84c0c2c3abb0cf7e815c5ae259face40ac977;p=libs%2Fcore.git diff --git a/source/jisx0208.cpp b/source/jisx0208.cpp index 4d46f70..1e5aec7 100644 --- a/source/jisx0208.cpp +++ b/source/jisx0208.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspstrings +Copyright © 2006-2007 Mikko Rasa +Distributed under the LGPL +*/ + #include "jisx0208.h" #include "jisx0208.table" @@ -9,10 +16,13 @@ namespace Msp { 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"); } @@ -30,21 +40,19 @@ void JisX0208::Decoder::decode_char(const string &str, string::const_iterator &i 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)