]> git.tdb.fi Git - libs/core.git/blobdiff - source/iso2022jp.cpp
Further style and comment adjustments
[libs/core.git] / source / iso2022jp.cpp
index 4d3a1dffd97df07171b61e0dce312cb54037124b..d9c7ceac147b0e08ccd3e8c3c684dce6cb947722 100644 (file)
@@ -20,33 +20,33 @@ void Iso2022Jp::Encoder::encode_char(UnicodeChar ch, string &buf)
        {
                if(mode!=ASCII && mode!=JISX0201)
                        switch_mode(ASCII, buf);
-               buf+=ch;
+               buf += ch;
        }
        else if(ch==0x5C || ch==0x7E)
        {
                if(mode!=ASCII)
                        switch_mode(ASCII, buf);
-               buf+=ch;
+               buf += ch;
        }
        else if(ch==0xA5 || ch==0x203E)
        {
                if(mode!=JISX0201)
                        switch_mode(JISX0201, buf);
                if(ch==0xA5)
-                       buf+=0x5C;
+                       buf += 0x5C;
                else if(ch==0x203E)
-                       buf+=0x7E;
+                       buf += 0x7E;
        }
        else
        {
-               Kuten jis=ucs_to_jisx0208(ch);
+               Kuten jis = ucs_to_jisx0208(ch);
                if(!jis)
                        return error(ch, buf, "Can't express character in ISO-2022-JP");
 
                if(mode!=JISX0208)
                        switch_mode(JISX0208, buf);
 
-               char jbuf[2]={jis.ku+0x20, jis.ten+0x20};
+               char jbuf[2] = {jis.ku+0x20, jis.ten+0x20};
                buf.append(jbuf, 2);
        }
 }
@@ -59,12 +59,12 @@ void Iso2022Jp::Encoder::sync(string &buf)
 
 void Iso2022Jp::Encoder::reset()
 {
-       mode=ASCII;
+       mode = ASCII;
 }
 
 void Iso2022Jp::Encoder::switch_mode(Mode m, string &buf)
 {
-       mode=m;
+       mode = m;
        switch(mode)
        {
        case ASCII:    buf.append("\033(B", 3); break;
@@ -78,7 +78,7 @@ void Iso2022Jp::Encoder::transliterate(UnicodeChar, string &buf)
 {
        if(mode!=ASCII)
                switch_mode(ASCII, buf);
-       buf+='?';
+       buf += '?';
 }
 
 
@@ -95,33 +95,33 @@ UnicodeChar Iso2022Jp::Decoder::decode_char(const string &str, string::const_ite
 
        while(i!=str.end())
        {
-               string::const_iterator j=i;
+               string::const_iterator j = i;
 
-               UnicodeChar result=-1;
+               UnicodeChar result = -1;
                if(*j==033)
                {
-                       unsigned escape=0;
+                       unsigned escape = 0;
                        for(++j; j!=str.end(); ++j)
                        {
-                               escape=escape<<8 | static_cast<unsigned char>(*j);
+                               escape = escape<<8 | static_cast<unsigned char>(*j);
                                if(*j>='@' && *j<='Z')
                                        break;
                        }
 
-                       bool ok=true;
+                       bool ok = true;
                        switch(escape)
                        {
                        case 0x2842: switch_mode(ASCII); break;    // ESC ( B
                        case 0x284A: switch_mode(JISX0201); break; // ESC ( J
                        case 0x2440:                               // ESC $ @
                        case 0x2442: switch_mode(JISX0208); break; // ESC $ B
-                       default: ok=false;
+                       default: ok = false;
                        }
 
                        if(ok)
-                               i=j;
+                               i = j;
                        else
-                               result=*i;
+                               result = *i;
                        ++i;
                }
                else if(dec)
@@ -139,20 +139,20 @@ UnicodeChar Iso2022Jp::Decoder::decode_char(const string &str, string::const_ite
 void Iso2022Jp::Decoder::reset()
 {
        delete dec;
-       mode=ASCII;
-       dec=new Ascii::Decoder;
+       mode = ASCII;
+       dec = new Ascii::Decoder;
 }
 
 void Iso2022Jp::Decoder::switch_mode(Mode m)
 {
        delete dec;
 
-       mode=m;
+       mode = m;
        switch(mode)
        {
-       case ASCII: dec=new Ascii::Decoder; break;
-       case JISX0201: dec=new JisX0201::Decoder; break;
-       case JISX0208: dec=new JisX0208::Decoder; break;
+       case ASCII: dec = new Ascii::Decoder; break;
+       case JISX0201: dec = new JisX0201::Decoder; break;
+       case JISX0208: dec = new JisX0208::Decoder; break;
        }
 }