X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcodec.cpp;fp=source%2Fcodec.cpp;h=0014847a67cebd30a12585980f466cdf7e5ea98c;hp=42315e52e9f7179540bcb5836021328f470cee2b;hb=5b1368cb791cab043f0435628cacbaff36e39b7b;hpb=36f9e78ae75f5e14b132f37d249340ad3480b8ce diff --git a/source/codec.cpp b/source/codec.cpp index 42315e5..0014847 100644 --- a/source/codec.cpp +++ b/source/codec.cpp @@ -23,8 +23,8 @@ namespace Codecs { bool Codec::detect(const string &str) const { - Decoder *dec=create_decoder(); - bool result=true; + Decoder *dec = create_decoder(); + bool result = true; try { for(string::const_iterator i=str.begin(); i!=str.end(); ) @@ -32,7 +32,7 @@ bool Codec::detect(const string &str) const } catch(const CodecError &) { - result=false; + result = false; } delete dec; @@ -72,9 +72,9 @@ void Codec::Decoder::decode(const string &str, ustring &buf) { for(string::const_iterator i=str.begin(); i!=str.end();) { - UnicodeChar c=decode_char(str, i); + UnicodeChar c = decode_char(str, i); if(c!=-1) - buf+=c; + buf += c; } } @@ -104,9 +104,9 @@ Codec *create_codec(const string &n) for(string::const_iterator i=n.begin(); i!=n.end(); ++i) { if(isupper(*i)) - name+=tolower(*i); + name += tolower(*i); else if(islower(*i) || isdigit(*i)) - name+=*i; + name += *i; } if(name=="ascii") return new Ascii; @@ -123,32 +123,32 @@ Codec *create_codec(const string &n) Codec *detect_codec(const string &str) { - bool is_utf8=true; - bool is_ascii=true; - bool is_latin1=true; - unsigned utf8_mb=0; + bool is_utf8 = true; + bool is_ascii = true; + bool is_latin1 = true; + unsigned utf8_mb = 0; for(string::const_iterator i=str.begin(); i!=str.end(); ++i) { - unsigned char c=*i; + unsigned char c = *i; if(c&0x80) { - is_ascii=false; + is_ascii = false; if((c&0xC0)==0x80) { if((c&0xE0)==0x80) - is_latin1=false; + is_latin1 = false; if(utf8_mb) --utf8_mb; else - is_utf8=false; + is_utf8 = false; } else if((c&0xC0)==0xC0) { if(utf8_mb) { - is_utf8=false; - utf8_mb=0; + is_utf8 = false; + utf8_mb = 0; } else { @@ -158,8 +158,8 @@ Codec *detect_codec(const string &str) } else if(utf8_mb) { - is_utf8=false; - utf8_mb=0; + is_utf8 = false; + utf8_mb = 0; } }