Diffstat (limited to 'noncore/apps/opie-reader/CEncoding.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CEncoding.cpp | 182 |
1 files changed, 121 insertions, 61 deletions
diff --git a/noncore/apps/opie-reader/CEncoding.cpp b/noncore/apps/opie-reader/CEncoding.cpp index 18d18d3..c1dcfe8 100644 --- a/noncore/apps/opie-reader/CEncoding.cpp +++ b/noncore/apps/opie-reader/CEncoding.cpp @@ -1,20 +1,26 @@ #include <stdio.h> #include "CEncoding.h" -tchar CUtf8::getch() +void CUtf8::getch(tchar& ch, CStyle& sty) { - int iret = parent->getch(); - if (iret == EOF) return UEOF; + int iret; + parent->getch(iret, sty); + if (iret == EOF) + { + ch = UEOF; + return; + } tchar ret = iret; int count = 0; if (ret & (1 << 7)) { unsigned char flags = ret << 1; while ((flags & (1 << 7)) != 0) { ret <<= 6; - ret += parent->getch() & 0x3f; + parent->getch(iret, sty); + ret += iret & 0x3f; flags <<= 1; count++; } switch (count) @@ -32,119 +38,173 @@ tchar CUtf8::getch() default: printf("Only 16bit unicode supported..."); } } - return ret; + ch = ret; + return; } - -tchar CUcs16be::getch() +void CUcs16be::getch(tchar& ch, CStyle& sty) { - int iret = parent->getch(); - if (iret == EOF) return UEOF; + int iret; + parent->getch(iret, sty); + if (iret == EOF) + { + ch = UEOF; + return; + } tchar ret = iret; - return (ret << 8) + parent->getch(); + parent->getch(iret, sty); + ch = (ret << 8) + iret; } -tchar CUcs16le::getch() +void CUcs16le::getch(tchar& ch, CStyle& sty) { - int iret = parent->getch(); - if (iret == EOF) return UEOF; + int iret; + parent->getch(iret, sty); + if (iret == EOF) + { + ch = UEOF; + return; + } tchar ret = iret; - return ret + (parent->getch() << 8); + parent->getch(iret, sty); + ch = ret + (iret << 8); } -tchar Ccp1252::getch() +void Ccp1252::getch(tchar& ch, CStyle& sty) { - int iret = parent->getch(); - switch (iret) + int iret; + parent->getch(iret, sty); + ch = iret; + switch (ch) { case EOF: - return UEOF; + ch = UEOF; + break; case 0x80: - return 0x20ac; + ch = 0x20ac; + break; case 0x82: - return 0x201a; + ch = 0x201a; + break; case 0x83: - return 0x0192; + ch = 0x0192; + break; case 0x84: - return 0x201e; + ch = 0x201e; + break; case 0x85: - return 0x2026; + ch = 0x2026; + break; case 0x86: - return 0x2020; + ch = 0x2020; + break; case 0x87: - return 0x2021; + ch = 0x2021; + break; case 0x88: - return 0x02c6; + ch = 0x02c6; + break; case 0x89: - return 0x2030; + ch = 0x2030; + break; case 0x8a: - return 0x0160; + ch = 0x0160; + break; case 0x8b: - return 0x2039; + ch = 0x2039; + break; case 0x8c: - return 0x0152; + ch = 0x0152; + break; case 0x8e: - return 0x017d; + ch = 0x017d; + break; case 0x91: - return 0x2018; + ch = 0x2018; + break; case 0x92: - return 0x2019; + ch = 0x2019; + break; case 0x93: - return 0x201c; + ch = 0x201c; + break; case 0x94: - return 0x201d; + ch = 0x201d; + break; case 0x95: - return 0x2022; + ch = 0x2022; + break; case 0x96: - return 0x2013; + ch = 0x2013; + break; case 0x97: - return 0x2014; + ch = 0x2014; + break; case 0x98: - return 0x02dc; + ch = 0x02dc; + break; case 0x99: - return 0x2122; + ch = 0x2122; + break; case 0x9a: - return 0x0161; + ch = 0x0161; + break; case 0x9b: - return 0x203a; + ch = 0x203a; + break; case 0x9c: - return 0x0153; + ch = 0x0153; + break; case 0x9e: - return 0x017e; + ch = 0x017e; + break; case 0x9f: - return 0x0178; + ch = 0x0178; + break; default: - return iret; + break; } } -tchar CPalm::getch() +void CPalm::getch(tchar& ch, CStyle& sty) { - tchar iret = Ccp1252::getch(); - switch (iret) + Ccp1252::getch(ch, sty); + switch (ch) { case 0x18: - return 0x2026; + ch = 0x2026; + break; case 0x19: - return 0x2007; + ch = 0x2007; + break; case 0x8d: - return 0x2662; + ch = 0x2662; + break; case 0x8e: - return 0x2663; + ch = 0x2663; + break; case 0x8f: - return 0x2661; + ch = 0x2661; + break; case 0x90: - return 0x2660; + ch = 0x2660; + break; default: - return iret; + break; } } -tchar CAscii::getch() +void CAscii::getch(tchar& ch, CStyle& sty) { - int iret = parent->getch(); - if (iret == EOF) return UEOF; - return iret; + int iret; + parent->getch(iret, sty); + if (iret == EOF) + { + ch = UEOF; + } + else + { + ch = iret; + } } - |