Changeset 3667
- Timestamp:
- 2003-01-13T20:12:09+13:00 (21 years ago)
- Location:
- trunk/gsdl/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/gsdlunicode.cpp
r1927 r3667 90 90 91 91 92 // this works for all unicode values < 65536... 93 void utf16outconvertclass::convert (char *out, size_t maxlen, size_t &len, status_t &status) { 94 // we should already have text_t* input set... 95 if (input == NULL || out == NULL) 96 { 97 status = finished; 98 return; 99 } 100 unsigned char *output = (unsigned char *)out; 101 text_t::iterator textend = input->end(); 102 len = 0; 103 if (maxlen % 2) maxlen--; // we need an even number of output bytes... 104 while ((len < maxlen) && (texthere != textend)) { 105 unsigned short int uni_char=(unsigned short int) *texthere; 106 // big endian utf-16... 107 if (uni_char < 256) { 108 out[len]=0; 109 out[len+1]=uni_char; 110 } else { 111 out[len]=uni_char >> 8; 112 out[len+1]=uni_char & 255; 113 } 114 len+=2; 115 ++texthere; 116 } 117 if (texthere==textend) 118 status=finished; 119 else 120 status=unfinished; 121 } 122 92 123 93 124 utf8inconvertclass::utf8inconvertclass () { -
trunk/gsdl/lib/gsdlunicode.h
r1927 r3667 39 39 // encoded text_t string 40 40 text_t to_uni (const text_t &in); 41 42 43 41 44 42 #define MAXUTF8CHARLEN 3 … … 78 76 }; 79 77 78 // utf16 is almost the same as unicode, except for unicode values > 65535. 79 class utf16outconvertclass : public rzwsoutconvertclass { 80 public: 81 utf16outconvertclass () {}; 82 void convert (char *out, size_t maxlen, size_t &len, status_t &status); 83 }; 84 80 85 81 86 // Convert from a text_t class to a utf-8 char stream
Note:
See TracChangeset
for help on using the changeset viewer.