1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Copyright (c) 2002-2005, International Business Machines 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef _CONVPERF_H 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define _CONVPERF_H 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <mlang.h> 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <objbase.h> 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <stdlib.h> 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ucnv.h" 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uclean.h" 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ustring.h" 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uperf.h" 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CONVERSION_FLAGS (0) /*WC_DEFAULTCHAR WC_COMPOSITECHECK & WC_SEPCHARS*/ 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MAX_BUF_SIZE 3048 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0])) 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass ICUToUnicodePerfFunction : public UPerfFunction{ 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UConverter* conv; 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* src; 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t srcLen; 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* target; 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* targetLimit; 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ICUToUnicodePerfFunction(const char* name, const char* source, int32_t sourceLen, UErrorCode& status){ 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru conv = ucnv_open(name,&status); 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(status)){ 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru conv = NULL; 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru target = NULL; 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru targetLimit = NULL; 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t reqdLen = ucnv_toUChars(conv, target, 0, 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru source, srcLen, &status); 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(status==U_BUFFER_OVERFLOW_ERROR) { 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru status=U_ZERO_ERROR; 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru target=(UChar*)malloc((reqdLen) * U_SIZEOF_UCHAR*2); 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru targetLimit = target + reqdLen; 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(target == NULL){ 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru status = U_MEMORY_ALLOCATION_ERROR; 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* mySrc = src; 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* sourceLimit = src + srcLen; 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* myTarget = target; 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ucnv_toUnicode(conv, &myTarget, targetLimit, &mySrc, sourceLimit, NULL, TRUE, status); 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ~ICUToUnicodePerfFunction(){ 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru free(target); 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ucnv_close(conv); 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass ICUFromUnicodePerfFunction : public UPerfFunction{ 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UConverter* conv; 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar* src; 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t srcLen; 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char* target; 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char* targetLimit; 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* name; 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ICUFromUnicodePerfFunction(const char* name, const UChar* source, int32_t sourceLen, UErrorCode& status){ 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru conv = ucnv_open(name,&status); 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(U_FAILURE(status)){ 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru conv = NULL; 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru target = NULL; 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru targetLimit = NULL; 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t reqdLen = ucnv_fromUChars(conv, target, 0, 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru source, srcLen, &status); 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(status==U_BUFFER_OVERFLOW_ERROR) { 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru status=U_ZERO_ERROR; 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru target=(char*)malloc((reqdLen*2)); 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru targetLimit = target + reqdLen; 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(target == NULL){ 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru status = U_MEMORY_ALLOCATION_ERROR; 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar* mySrc = src; 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar* sourceLimit = src + srcLen; 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char* myTarget = target; 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ucnv_fromUnicode(conv,&myTarget, targetLimit, &mySrc, sourceLimit, NULL, TRUE, status); 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ~ICUFromUnicodePerfFunction(){ 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru free(target); 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ucnv_close(conv); 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass ICUOpenAllConvertersFunction : public UPerfFunction{ 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool cleanup; 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t availableConverters; 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char **convNames; 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ICUOpenAllConvertersFunction(UBool callCleanup, UErrorCode& status){ 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t idx; 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru cleanup = callCleanup; 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru availableConverters = ucnv_countAvailable(); 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru convNames = new const char *[availableConverters]; 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for (idx = 0; idx < availableConverters; idx++) { 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru convNames[idx] = ucnv_getAvailableName(idx); 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t idx; 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (cleanup) { 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru u_cleanup(); 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for (idx = 0; idx < availableConverters; idx++) { 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ucnv_close(ucnv_open(convNames[idx], status)); 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return availableConverters; 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ~ICUOpenAllConvertersFunction(){ 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru delete []convNames; 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass WinANSIToUnicodePerfFunction : public UPerfFunction{ 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DWORD uiCodePage; 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char* src; 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT srcLen; 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WCHAR dest[MAX_BUF_SIZE]; 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT dstLen; 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* name; 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WinANSIToUnicodePerfFunction(const char* cpName, char* pszIn,UINT szLen, UErrorCode& status){ 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru name = cpName; 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = pszIn; 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = szLen; 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dstLen = LENGTHOF(dest); 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru unsigned short bEnc[30]={'\0'}; 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* tenc=name; 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int i=0;*tenc!='\0';i++){ 166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru bEnc[i]=*tenc; 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru tenc++; 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMULTILANGUAGE2 pMulti; 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoInitialize(NULL); 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* create instance of converter object*/ 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoCreateInstance( 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(CMultiLanguage), 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NULL, 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CLSCTX_SERVER, 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(IMultiLanguage2), 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru (void**)&pMulti 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru MIMECSETINFO mimeInfo; 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiCodePage = 0; 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiInternetEncoding =0; 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* get the charset info */ 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->GetCharsetInfo((wchar_t *)bEnc,&mimeInfo); 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uiCodePage = (mimeInfo.uiInternetEncoding==0)?mimeInfo.uiCodePage:mimeInfo.uiInternetEncoding; 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int winSize =MultiByteToWideChar(uiCodePage,CONVERSION_FLAGS,src,srcLen,dest,dstLen); 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass WinANSIFromUnicodePerfFunction : public UPerfFunction{ 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DWORD uiCodePage; 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WCHAR* src; 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT srcLen; 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char dest[MAX_BUF_SIZE]; 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT dstLen; 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* name; 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru BOOL lpUsedDefaultChar; 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WinANSIFromUnicodePerfFunction(const char* cpName, WCHAR* pszIn,UINT szLen, UErrorCode& status){ 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru name = cpName; 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = pszIn; 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = szLen; 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dstLen = LENGTHOF(dest); 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru lpUsedDefaultChar=FALSE; 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru unsigned short bEnc[30]={'\0'}; 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* tenc=name; 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int i=0;*tenc!='\0';i++){ 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru bEnc[i]=*tenc; 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru tenc++; 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMULTILANGUAGE2 pMulti; 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoInitialize(NULL); 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* create instance of converter object*/ 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoCreateInstance( 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(CMultiLanguage), 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NULL, 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CLSCTX_SERVER, 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(IMultiLanguage2), 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru (void**)&pMulti 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru MIMECSETINFO mimeInfo; 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiCodePage = 0; 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiInternetEncoding =0; 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* get the charset info */ 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->GetCharsetInfo((wchar_t *)bEnc,&mimeInfo); 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uiCodePage = (mimeInfo.uiInternetEncoding==0)?mimeInfo.uiCodePage:mimeInfo.uiInternetEncoding; 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru BOOL* pUsedDefaultChar =(uiCodePage==CP_UTF8)?NULL:&lpUsedDefaultChar; 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int winSize = WideCharToMultiByte(uiCodePage,CONVERSION_FLAGS,src,srcLen,dest,dstLen,NULL, pUsedDefaultChar); 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic inline void getErr(HRESULT err, UErrorCode& status){ 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru switch (err){ 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case S_OK: 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //printf("Operation %s successful\n",operation); 260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru break; 261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case S_FALSE: 262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru status = U_INTERNAL_PROGRAM_ERROR; 263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru break; 264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case E_FAIL: 265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru status = U_ILLEGAL_CHAR_FOUND; 266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass WinIMultiLanguageToUnicodePerfFunction : public UPerfFunction{ 269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMULTILANGUAGE2 pMulti; 272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMLANGCONVERTCHARSET pConvToUni; 273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char* src; 274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT srcLen; 275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WCHAR dst[MAX_BUF_SIZE]; 276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT dstLen; 277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* cpName; 278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WinIMultiLanguageToUnicodePerfFunction(const char* name,char* source, UINT sourceLen, UErrorCode& status){ 281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoInitialize(NULL); 283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* create instance of converter object*/ 285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoCreateInstance( 286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(CMultiLanguage), 287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NULL, 288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CLSCTX_SERVER, 289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(IMultiLanguage2), 290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru (void**)&pMulti 291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru MIMECSETINFO mimeInfo; 296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiCodePage = 0; 297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiInternetEncoding =0; 298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru HRESULT err=S_OK; 299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru unsigned short bEnc[30]={'\0'}; 300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* tenc=name; 301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int i=0;*tenc!='\0';i++){ 302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru bEnc[i]=*tenc; 303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru tenc++; 304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* get the charset info */ 306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->GetCharsetInfo((wchar_t *)bEnc,&mimeInfo); 307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->CreateConvertCharset(mimeInfo.uiCodePage, 1200 /*unicode*/, (DWORD)0,&pConvToUni); 308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru getErr(err,status); 309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dstLen = LENGTHOF(dst); 312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru cpName = name; 313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru HRESULT err= pConvToUni->DoConversionToUnicode(src,&srcLen,dst, &dstLen); 317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru getErr(err,*status); 318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass WinIMultiLanguageFromUnicodePerfFunction : public UPerfFunction{ 325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMULTILANGUAGE2 pMulti; 328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMLANGCONVERTCHARSET pConvFromUni; 329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WCHAR* src; 330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT srcLen; 331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char dst[MAX_BUF_SIZE]; 332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT dstLen; 333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* cpName; 334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WinIMultiLanguageFromUnicodePerfFunction(const char* name,WCHAR* source, UINT sourceLen, UErrorCode& status){ 337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoInitialize(NULL); 339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* create instance of converter object*/ 341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoCreateInstance( 342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(CMultiLanguage), 343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NULL, 344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CLSCTX_SERVER, 345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(IMultiLanguage2), 346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru (void**)&pMulti 347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru MIMECSETINFO mimeInfo; 352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiCodePage = 0; 353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiInternetEncoding =0; 354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru HRESULT err=S_OK; 355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru unsigned short bEnc[30]={'\0'}; 356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* tenc=name; 357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int i=0;*tenc!='\0';i++){ 358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru bEnc[i]=*tenc; 359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru tenc++; 360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* get the charset info */ 362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->GetCharsetInfo((wchar_t *)bEnc,&mimeInfo); 363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->CreateConvertCharset(1200 /*unicode*/, mimeInfo.uiCodePage, (DWORD)0,&pConvFromUni); 364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru getErr(err,status); 365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dstLen = LENGTHOF(dst); 368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru cpName = name; 369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru HRESULT err= pConvFromUni->DoConversionFromUnicode(src,&srcLen,dst, &dstLen); 374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru getErr(err,*status); 375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass WinIMultiLanguage2ToUnicodePerfFunction : public UPerfFunction{ 382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMULTILANGUAGE2 pMulti; 385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char* src; 386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT srcLen; 387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WCHAR dst[MAX_BUF_SIZE]; 388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT dstLen; 389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* cpName; 390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DWORD dwEnc; 391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WinIMultiLanguage2ToUnicodePerfFunction(const char* name,char* source, UINT sourceLen, UErrorCode& status){ 393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoInitialize(NULL); 395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* create instance of converter object*/ 397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoCreateInstance( 398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(CMultiLanguage), 399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NULL, 400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CLSCTX_SERVER, 401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(IMultiLanguage2), 402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru (void**)&pMulti 403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dstLen = LENGTHOF(dst); 408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru cpName = name; 409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru unsigned short bEnc[30]={'\0'}; 410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* tenc=name; 411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int i=0;*tenc!='\0';i++){ 412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru bEnc[i]=*tenc; 413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru tenc++; 414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* get the charset info */ 416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru MIMECSETINFO mimeInfo; 417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiCodePage = 0; 418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiInternetEncoding =0; 419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->GetCharsetInfo((wchar_t *)bEnc,&mimeInfo); 420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dwEnc = (mimeInfo.uiInternetEncoding==0)?mimeInfo.uiCodePage:mimeInfo.uiInternetEncoding; 421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DWORD dwMode=0; 425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru HRESULT err= pMulti->ConvertStringToUnicode(&dwMode,dwEnc,(char*)src,&srcLen,dst, &dstLen); 426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru getErr(err,*status); 427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass WinIMultiLanguage2FromUnicodePerfFunction : public UPerfFunction{ 434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMULTILANGUAGE2 pMulti; 437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LPMLANGCONVERTCHARSET pConvFromUni; 438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WCHAR* src; 439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT srcLen; 440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char dst[MAX_BUF_SIZE]; 441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UINT dstLen; 442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* cpName; 443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DWORD dwEnc; 444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru WinIMultiLanguage2FromUnicodePerfFunction(const char* name,WCHAR* source, UINT sourceLen, UErrorCode& status){ 447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoInitialize(NULL); 449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* create instance of converter object*/ 451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CoCreateInstance( 452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(CMultiLanguage), 453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NULL, 454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CLSCTX_SERVER, 455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru __uuidof(IMultiLanguage2), 456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru (void**)&pMulti 457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru unsigned short bEnc[30]={'\0'}; 461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* tenc=name; 462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int i=0;*tenc!='\0';i++){ 463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru bEnc[i]=*tenc; 464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru tenc++; 465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dstLen = LENGTHOF(dst); 469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru cpName = name; 470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* get the charset info */ 471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru MIMECSETINFO mimeInfo; 472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiCodePage = 0; 473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mimeInfo.uiInternetEncoding =0; 474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pMulti->GetCharsetInfo((wchar_t *)bEnc,&mimeInfo); 476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru dwEnc = (mimeInfo.uiInternetEncoding==0)?mimeInfo.uiCodePage:mimeInfo.uiInternetEncoding; 477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru DWORD dwMode=0; 481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru HRESULT err= pMulti->ConvertStringFromUnicode(&dwMode,dwEnc,src,&srcLen,dst, &dstLen); 482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru getErr(err,*status); 483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(void){ 485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass ConverterPerformanceTest : public UPerfTest{ 490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ConverterPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status); 494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ~ConverterPerformanceTest(); 495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,const char* &name, char* par = NULL); 496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_CleanOpenAllConverters(); 498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_OpenAllConverters(); 499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_UTF8_ToUnicode(); 501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_UTF8_FromUnicode(); 502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_UTF8_ToUnicode(); 503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_UTF8_FromUnicode(); 504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_UTF8_ToUnicode(); 505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_UTF8_FromUnicode(); 506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_Latin1_ToUnicode(); 508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_Latin1_FromUnicode(); 509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_Latin1_ToUnicode(); 510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_Latin1_FromUnicode(); 511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_Latin1_ToUnicode(); 512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_Latin1_FromUnicode(); 513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_EBCDIC_Arabic_ToUnicode(); 515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_EBCDIC_Arabic_FromUnicode(); 516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_EBCDIC_Arabic_ToUnicode(); 517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_EBCDIC_Arabic_FromUnicode(); 518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_EBCDIC_Arabic_ToUnicode(); 519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_EBCDIC_Arabic_FromUnicode(); 520ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_Latin8_ToUnicode(); 522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_Latin8_FromUnicode(); 523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_Latin8_ToUnicode(); 524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_Latin8_FromUnicode(); 525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_Latin8_ToUnicode(); 526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_Latin8_FromUnicode(); 527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_SJIS_ToUnicode(); 530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_SJIS_FromUnicode(); 531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_SJIS_ToUnicode(); 532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_SJIS_FromUnicode(); 533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_SJIS_ToUnicode(); 534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_SJIS_FromUnicode(); 535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_EUCJP_ToUnicode(); 537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_EUCJP_FromUnicode(); 538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_EUCJP_ToUnicode(); 539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_EUCJP_FromUnicode(); 540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_EUCJP_ToUnicode(); 541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_EUCJP_FromUnicode(); 542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_GB2312_ToUnicode(); 544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_GB2312_FromUnicode(); 545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_GB2312_ToUnicode(); 546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_GB2312_FromUnicode(); 547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_GB2312_ToUnicode(); 548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_GB2312_FromUnicode(); 549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_ISO2022KR_ToUnicode(); 552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_ISO2022KR_FromUnicode(); 553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_ISO2022KR_ToUnicode(); 554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_ISO2022KR_FromUnicode(); 555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_ISO2022KR_ToUnicode(); 556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_ISO2022KR_FromUnicode(); 557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_ISO2022JP_ToUnicode(); 559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_ISO2022JP_FromUnicode(); 560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_ISO2022JP_ToUnicode(); 561ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinANSI_ISO2022JP_FromUnicode(); 562ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_ISO2022JP_ToUnicode(); 563ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWinIML2_ISO2022JP_FromUnicode(); 564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 566ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 567ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 569