15 #include "stringDecoder.h" 16 #include "config_dtoolutil.h" 18 ostream *StringDecoder::_notify_ptr = &cerr;
39 return (
unsigned char)_input[_p++];
53 _notify_ptr = notify_ptr;
100 while (!test_eof()) {
101 result = (
unsigned char)_input[_p++];
102 if ((result & 0x80) == 0) {
106 }
if ((result & 0xe0) == 0xc0) {
108 unsigned int two = 0;
110 if (_notify_ptr != NULL) {
112 <<
"utf-8 encoded string '" << _input <<
"' ends abruptly.\n";
116 two = (
unsigned char)_input[_p++];
117 result = ((result & 0x1f) << 6) | (two & 0x3f);
120 }
else if ((result & 0xf0) == 0xe0) {
123 if (_notify_ptr != NULL) {
125 <<
"utf-8 encoded string '" << _input <<
"' ends abruptly.\n";
129 unsigned int two = (
unsigned char)_input[_p++];
131 if (_notify_ptr != NULL) {
133 <<
"utf-8 encoded string '" << _input <<
"' ends abruptly.\n";
137 unsigned int three = (
unsigned char)_input[_p++];
138 result = ((result & 0x0f) << 12) | ((two & 0x3f) << 6) | (three & 0x3f);
144 if (_notify_ptr != NULL) {
146 <<
"Non utf-8 byte in string: 0x" << hex << result << dec
147 <<
", string is '" << _input <<
"'\n";
167 unsigned int high = (
unsigned char)_input[_p++];
169 if (_notify_ptr != NULL) {
171 <<
"Unicode-encoded string has odd number of bytes.\n";
175 unsigned int low = (
unsigned char)_input[_p++];
176 return ((high << 8) | low);
virtual int get_next_character()
Returns the next character in sequence.
virtual int get_next_character()
Returns the next character in sequence.
virtual int get_next_character()
Returns the next character in sequence.
static ostream * get_notify_ptr()
Returns the ostream that is used to write error messages to.
static void set_notify_ptr(ostream *ptr)
Sets the ostream that is used to write error messages to.