From 4de93aa65da7067c8d253f073435e8d8ae5b1da9 Mon Sep 17 00:00:00 2001 From: "paulg@google.com" Date: Wed, 20 Aug 2008 23:47:42 +0000 Subject: Final character conversions for net_util. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1132 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/net_util.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'net') diff --git a/net/base/net_util.cc b/net/base/net_util.cc index a12b4d8..e0cbd04 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -620,11 +620,24 @@ void IDNToUnicodeOneComponent(const wchar_t* comp, } while (true) { - out->resize(out->size() + extra_space); UErrorCode status = U_ZERO_ERROR; - int output_chars = uidna_IDNToUnicode( - comp, comp_len, &(*out)[host_begin_in_output], extra_space, - UIDNA_DEFAULT, NULL, &status); +#if defined(WCHAR_T_IS_UTF32) + std::string16 comp16; + WideToUTF16(comp, comp_len, &comp16); + std::string16 out16; + WideToUTF16(out->c_str(), out->length(), &out16); + out16.resize(out16.size() + extra_space); + int output_chars = + uidna_IDNToUnicode(comp16.data(), static_cast(comp16.length()), + &(out16)[host_begin_in_output], extra_space, + UIDNA_DEFAULT, NULL, &status); + *out = UTF16ToWide(out16); +#else + out->resize(out->size() + extra_space); + int output_chars = + uidna_IDNToUnicode(comp, comp_len, &(*out)[host_begin_in_output], + extra_space, UIDNA_DEFAULT, NULL, &status); +#endif if (status == U_ZERO_ERROR) { // Converted successfully. out->resize(host_begin_in_output + output_chars); -- cgit v1.1