Changeset 650 for trunk/src/unicode.cpp
- Timestamp:
- 02/18/08 16:40:34 (3 years ago)
- Files:
-
- 1 modified
-
trunk/src/unicode.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/unicode.cpp
r621 r650 77 77 #endif 78 78 79 79 /* 80 80 inline std::wstring to_unicode(std::string const& text) 81 81 { … … 160 160 } 161 161 162 162 */ 163 163 transcoder::transcoder (std::string const& encoding) 164 : ok_(false), 165 conv_(0) 164 166 { 165 167 #ifdef MAPNIK_DEBUG … … 167 169 #endif 168 170 169 #ifndef WORDS_BIGENDIAN 170 desc_ = iconv_open("UCS-4LE",encoding.c_str()); 171 #else 172 desc_ = iconv_open("UCS-4BE",encoding.c_str()); 173 #endif 174 } 175 176 std::wstring transcoder::transcode(std::string const& input) const 177 { 171 //#ifndef WORDS_BIGENDIAN 172 // desc_ = iconv_open("UCS-4LE",encoding.c_str()); 173 //#else 174 // desc_ = iconv_open("UCS-4BE",encoding.c_str()); 175 //#endif 176 177 UErrorCode err = U_ZERO_ERROR; 178 conv_ = ucnv_open(encoding.c_str(),&err); 179 if (U_SUCCESS(err)) ok_ = true; 180 // TODO 181 } 182 183 UnicodeString transcoder::transcode(const char* data) const 184 { 185 186 UErrorCode err = U_ZERO_ERROR; 187 188 UnicodeString ustr(data,-1,conv_,err); 189 if (ustr.isBogus()) 190 { 191 ustr.remove(); 192 } 193 return ustr; 194 /* 178 195 if (desc_ == iconv_t(-1)) return to_unicode(input); 179 196 size_t inleft = input.size(); … … 197 214 #endif 198 215 return output; 216 */ 199 217 } 200 218 201 219 transcoder::~transcoder() 202 220 { 203 if (desc_ != iconv_t(-1)) iconv_close(desc_); 221 // if (desc_ != iconv_t(-1)) iconv_close(desc_); 222 if (conv_) 223 ucnv_close(conv_); 204 224 } 205 225 }
