From 4ec1a0365311f1253faaeedefc1eddceae5bfc20 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Thu, 25 Apr 2002 06:37:22 +0000 Subject: [PATCH] - Fix for bug #14353 --- ext/com/conversion.c | 8 ++++---- ext/rpc/com/conversion.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/com/conversion.c b/ext/com/conversion.c index ddb6dfbca4..e18c464e81 100644 --- a/ext/com/conversion.c +++ b/ext/com/conversion.c @@ -770,7 +770,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML if (strlen == -1) { /* request needed buffersize */ - strlen = MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0); + strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0); } else { /* \0 terminator */ strlen++; @@ -780,7 +780,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * strlen); /* convert string */ - error = !MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, strlen, unicode_str, strlen); + error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, strlen, unicode_str, strlen); } else { /* return a zero-length string */ unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR)); @@ -812,13 +812,13 @@ PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int cod uint length = 0; /* request needed buffersize */ - uint reqSize = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, NULL, 0, NULL, NULL); + uint reqSize = WideCharToMultiByte(codepage, codepage == CP_UTF8 ? 0 : WC_COMPOSITECHECK, unicode_str, -1, NULL, 0, NULL, NULL); if (reqSize) { C_str = (char *) emalloc(sizeof(char) * reqSize); /* convert string */ - length = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, C_str, reqSize, NULL, NULL) - 1; + length = WideCharToMultiByte(codepage, codepage == CP_UTF8 ? 0 : WC_COMPOSITECHECK, unicode_str, -1, C_str, reqSize, NULL, NULL) - 1; } else { C_str = (char *) emalloc(sizeof(char)); *C_str = 0; diff --git a/ext/rpc/com/conversion.c b/ext/rpc/com/conversion.c index ddb6dfbca4..e18c464e81 100644 --- a/ext/rpc/com/conversion.c +++ b/ext/rpc/com/conversion.c @@ -770,7 +770,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML if (strlen == -1) { /* request needed buffersize */ - strlen = MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0); + strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0); } else { /* \0 terminator */ strlen++; @@ -780,7 +780,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * strlen); /* convert string */ - error = !MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, strlen, unicode_str, strlen); + error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, strlen, unicode_str, strlen); } else { /* return a zero-length string */ unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR)); @@ -812,13 +812,13 @@ PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int cod uint length = 0; /* request needed buffersize */ - uint reqSize = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, NULL, 0, NULL, NULL); + uint reqSize = WideCharToMultiByte(codepage, codepage == CP_UTF8 ? 0 : WC_COMPOSITECHECK, unicode_str, -1, NULL, 0, NULL, NULL); if (reqSize) { C_str = (char *) emalloc(sizeof(char) * reqSize); /* convert string */ - length = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, C_str, reqSize, NULL, NULL) - 1; + length = WideCharToMultiByte(codepage, codepage == CP_UTF8 ? 0 : WC_COMPOSITECHECK, unicode_str, -1, C_str, reqSize, NULL, NULL) - 1; } else { C_str = (char *) emalloc(sizeof(char)); *C_str = 0; -- 2.50.1