summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CEncoding.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/CEncoding.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CEncoding.cpp150
1 files changed, 150 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/CEncoding.cpp b/noncore/apps/opie-reader/CEncoding.cpp
new file mode 100644
index 0000000..18d18d3
--- a/dev/null
+++ b/noncore/apps/opie-reader/CEncoding.cpp
@@ -0,0 +1,150 @@
1#include <stdio.h>
2#include "CEncoding.h"
3
4tchar CUtf8::getch()
5{
6 int iret = parent->getch();
7 if (iret == EOF) return UEOF;
8 tchar ret = iret;
9 int count = 0;
10 if (ret & (1 << 7))
11 {
12 unsigned char flags = ret << 1;
13 while ((flags & (1 << 7)) != 0)
14 {
15 ret <<= 6;
16 ret += parent->getch() & 0x3f;
17 flags <<= 1;
18 count++;
19 }
20 switch (count)
21 {
22 case 0:
23 break;
24 case 1:
25 ret &= 0x07ff;
26 break;
27 case 2:
28 break;
29 case 3:
30 case 4:
31 case 5:
32 default:
33 printf("Only 16bit unicode supported...");
34 }
35 }
36 return ret;
37}
38
39
40tchar CUcs16be::getch()
41{
42 int iret = parent->getch();
43 if (iret == EOF) return UEOF;
44 tchar ret = iret;
45 return (ret << 8) + parent->getch();
46}
47
48tchar CUcs16le::getch()
49{
50 int iret = parent->getch();
51 if (iret == EOF) return UEOF;
52 tchar ret = iret;
53 return ret + (parent->getch() << 8);
54}
55
56tchar Ccp1252::getch()
57{
58 int iret = parent->getch();
59 switch (iret)
60 {
61 case EOF:
62 return UEOF;
63 case 0x80:
64 return 0x20ac;
65 case 0x82:
66 return 0x201a;
67 case 0x83:
68 return 0x0192;
69 case 0x84:
70 return 0x201e;
71 case 0x85:
72 return 0x2026;
73 case 0x86:
74 return 0x2020;
75 case 0x87:
76 return 0x2021;
77 case 0x88:
78 return 0x02c6;
79 case 0x89:
80 return 0x2030;
81 case 0x8a:
82 return 0x0160;
83 case 0x8b:
84 return 0x2039;
85 case 0x8c:
86 return 0x0152;
87 case 0x8e:
88 return 0x017d;
89 case 0x91:
90 return 0x2018;
91 case 0x92:
92 return 0x2019;
93 case 0x93:
94 return 0x201c;
95 case 0x94:
96 return 0x201d;
97 case 0x95:
98 return 0x2022;
99 case 0x96:
100 return 0x2013;
101 case 0x97:
102 return 0x2014;
103 case 0x98:
104 return 0x02dc;
105 case 0x99:
106 return 0x2122;
107 case 0x9a:
108 return 0x0161;
109 case 0x9b:
110 return 0x203a;
111 case 0x9c:
112 return 0x0153;
113 case 0x9e:
114 return 0x017e;
115 case 0x9f:
116 return 0x0178;
117 default:
118 return iret;
119 }
120}
121
122tchar CPalm::getch()
123{
124 tchar iret = Ccp1252::getch();
125 switch (iret)
126 {
127 case 0x18:
128 return 0x2026;
129 case 0x19:
130 return 0x2007;
131 case 0x8d:
132 return 0x2662;
133 case 0x8e:
134 return 0x2663;
135 case 0x8f:
136 return 0x2661;
137 case 0x90:
138 return 0x2660;
139 default:
140 return iret;
141 }
142}
143
144tchar CAscii::getch()
145{
146 int iret = parent->getch();
147 if (iret == EOF) return UEOF;
148 return iret;
149}
150