Changeset 759 for trunk/include/mapnik/value.hpp
- Timestamp:
- 11/16/08 16:11:57 (8 weeks ago)
- Files:
-
- 1 modified
-
trunk/include/mapnik/value.hpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/mapnik/value.hpp
r693 r759 30 30 // boost 31 31 #include <boost/variant.hpp> 32 #include <boost/scoped_array.hpp> 32 33 // stl 33 34 #include <iostream> … … 37 38 // uci 38 39 #include <unicode/unistr.h> 40 #include <unicode/ustring.h> 41 39 42 40 43 namespace mapnik { 44 45 inline void to_utf8(UnicodeString const& input, std::string & target) 46 { 47 if (input.length() == 0) return; 48 49 const int BUF_SIZE = 256; 50 char buf [BUF_SIZE]; 51 int len; 52 53 UErrorCode err = U_ZERO_ERROR; 54 u_strToUTF8(buf, BUF_SIZE, &len, input.getBuffer(), input.length(), &err); 55 if (err == U_BUFFER_OVERFLOW_ERROR || err == U_STRING_NOT_TERMINATED_WARNING ) 56 { 57 boost::scoped_array<char> buf_ptr(new char [len+1]); 58 err = U_ZERO_ERROR; 59 u_strToUTF8(buf_ptr.get() , len + 1, &len, input.getBuffer(), input.length(), &err); 60 target.assign(buf_ptr.get() , len); 61 } 62 else 63 { 64 target.assign(buf, len); 65 } 66 } 41 67 42 68 struct value_null … … 506 532 std::string operator() (UnicodeString const& val) const 507 533 { 508 /* 509 std::stringstream ss; 510 UnicodeString::const_iterator pos = val.begin(); 511 ss << std::hex ; 512 for (;pos!=val.end();++pos) 513 { 514 wchar_t c = *pos; 515 if (c < 0x80) 516 { 517 ss << char(c); 518 } 519 else 520 { 521 ss << "\\x"; 522 unsigned c0 = (c >> 8) & 0xff; 523 if (c0) ss << c0; 524 ss << (c & 0xff); 525 } 526 } 527 return "\'" + ss.str() + "\'"; 528 */ 529 return "TODO"; 534 std::string utf8; 535 to_utf8(val,utf8); 536 return "'" + utf8 + "'"; 530 537 } 531 538
