string IceUtil::nativeToUTF8(const string& str, const IceUtil::StringConverterPtr& converter) { if(!converter || str.empty()) { return str; } UTF8BufferI buffer; Byte* last = converter->toUTF8(str.data(), str.data() + str.size(), buffer); return string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer()); }
string IceUtil::UTF8ToNative(const string& str, const IceUtil::StringConverterPtr& converter) { if(!converter || str.empty()) { return str; } string tmp; converter->fromUTF8(reinterpret_cast<const Byte*>(str.data()), reinterpret_cast<const Byte*>(str.data() + str.size()), tmp); return tmp; }
string IceUtil::nativeToUTF8(const string& str, const IceUtil::StringConverterPtr& converter) { if(!converter || str.empty()) { return str; } UTF8BufferI buffer; Byte* last = converter->toUTF8(str.data(), str.data() + str.size(), buffer); string result; buffer.swap(result, last); return result; }