1 #include <iostream>
2 #include <fstream>
3 #include <string>
4 #include <stack>
6 #include <oberon.h>
7 #include <reader.h>
8 #include <store.h>
9 #include <textmodel.h>
10 #include <visitor.h>
12 // Character encoding conversions
13 #include <locale.h>
14 #include <iconv.h>
15 #include <errno.h>
16 #include <string.h>
23 };
30 }
33 }
34 };
49 }
50 }
56 }
57 }
58 };
72 }
74 }
79 }
82 }
85 }
88 }
91 }
98 }
109 }
114 }
116 }
121 //d_convLong = iconv_open(setlocale(LC_CTYPE, 0), "UCS-2");
122 /*
123 iconv_t conv = iconv_open("UTF-8", "UTF-8");
124 if (conv == (iconv_t)-1) {
125 std::string str("iconv initialization error: ");
126 str += strerror(errno);
127 throw str.c_str();
128 }
129 size_t bytesIn = piece->size() + 1;
130 char *in = (char*)piece->getBuffer();
131 size_t bytesOut = bytesIn; // FIXME probably not safe.
132 char *out = new char[bytesIn];
133 char *outPtr = out;
134 size_t rval = iconv(conv, &in, &bytesIn, &outPtr, &bytesOut);
135 if (rval == (size_t)-1) {
136 std::string str("iconv error: ");
137 str += strerror(errno);
138 throw str.c_str();
139 }
140 iconv_close(conv);
141 std::string str(out);
142 for (std::string::iterator it = str.begin(); it < str.end(); ++it) {
143 if (*it == '\r') *it = '\n';
144 }
145 d_context.top()->addPiece(str);*/
146 }
147 };
158 }
161 }
163 }
164 }
169 }
171 // Set the locale according to the terminal's environment
185 }
186 // std::cout << s->toPlainText() << std::endl;
187 // std::cout << std::endl << std::endl;
195 }
196 // std::cout << s->toString() << std::endl;
197 // std::cout << in.tellg() << " " << in.eof() << std::endl;
199 // odc::TypePath path;
200 // odc::ContainerModel(0).getTypePath(&path);
201 // std::cout << path.toString() << std::endl;
203 }