From 4e848f2c696d0e6f3c7230f077266d1d82872b47 Mon Sep 17 00:00:00 2001 From: ntrifunovic Date: Fri, 25 Aug 2006 22:35:25 +0000 Subject: [PATCH] Added a utf16 > utf-8 test case for win32 performance test git-svn-id: http://svn.code.sf.net/p/utfcpp/code@51 a809a056-fc17-0410-9590-b4f493f8b08e --- test_drivers/performance/win32.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test_drivers/performance/win32.cpp b/test_drivers/performance/win32.cpp index f838dd2..0ddf980 100644 --- a/test_drivers/performance/win32.cpp +++ b/test_drivers/performance/win32.cpp @@ -58,7 +58,7 @@ int main(int argc, char** argv) wchar_t* utf16iconvbuf = new wchar_t[wlength]; { memset (utf16iconvbuf, 0 , wlength * sizeof(wchar_t)); - // iconv + // win32 cout << "win32: "; { @@ -72,7 +72,33 @@ int main(int argc, char** argv) if (!equal(utf16buf, utf16buf + wlength, utf16iconvbuf)) cout << "Different result!!!"; + // the other way around + cout << "UTF16 to UTF-8\n"; + { + //win32 + memset(buf, 0, length); + cout<< "win32: "; + { + timer t(cout); + WideCharToMultiByte(CP_UTF8, 0, utf16buf, wlength, buf, length, NULL, NULL); + } + } + + { + memset (buf, 0 , length); + // utf-8 cpp: + cout << "unchecked::utf16to8: "; + timer t(cout); + utf8::unchecked::utf16to8(utf16buf, utf16buf + wlength, buf); + } + + { + memset (buf, 0 , length); + cout << "utf16to8: "; + timer t(cout); + utf8::utf16to8(utf16buf, utf16buf + wlength, buf); + } delete [] buf; delete [] utf16buf;