Re: [boost] [string] Realistic API proposal

On 2011-01-28 23:04, Artyom<artyomtnk@yahoo.com> wrote:
// conversion for Windows API std::vector<wchar_t> vec; vec.resize(count_codepoints<utf8>(mystring.begin(), mystring.end())); convert<utf8,utf16>(mystring.begin(), mystring.end(), vec.begin()); HRESULT hr = WriteFile(handle, vec.data(), vec.size(),&dwBytesWritten, NULL); ...
Notice vector is not string and it requires additional copy
If std::string is UTF-8 encoded (as you are suggesting, correct?), then you also requires additional copy: // conversion for Windows API std::string u8s = ...; std::wstring u16s = convert_to_utf16(u8s); HANDLE h = CreateFileW(u16s.c_str(), ...); Regards, Anders Dalvander -- WWFSMD?

If std::string is UTF-8 encoded (as you are suggesting, correct?), then you also requires additional copy:
// conversion for Windows API std::string u8s = ...; std::wstring u16s = convert_to_utf16(u8s); HANDLE h = CreateFileW(u16s.c_str(), ...);
Regards, Anders Dalvander
Fortunately only under Windows, under rest of the normal OSes it would not require :-). Also the idea is also to have utf-8 aware API in boost for windows so you just call: boost::ofstream file(utf_name); Artyom
participants (2)
-
Anders Dalvander
-
Artyom