Ask a Question related to PHP Bugs, Design and Development.
-
fjortiz at comunet dot es #1
#40664 [NEW]: String conversion functions wrong for multibyte chars
From: fjortiz at comunet dot es
Operating system: Win32
PHP version: 5.2.1
PHP Bug Type: COM related
Bug description: String conversion functions wrong for multibyte chars
Description:
------------
when converting a UTF-8 encoded, multibyte string (Russian for example),
to a COM string, a wrong number of bytes are allocated, thus creating the
COM string with junk bytes at the end.
For example, when I pass my COM-based ADODB driver a 5-letter word in
Russian, I get at destination a 10 (5*2) characters string, the first 5
are the right Russian chars and the rest 5 are junk characters.
This was also explained for 4.4.2 in bug #37899
Actual result:
--------------
this is solved patching two files:
\ext\com_dotnet\com_variant.c, function php_com_variant_from_zval, line
156:
156,157c156
< V_BSTR(v) = SysAllocString((char*)olestring);
---sizeof(OLECHAR));> V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRLEN_P(z) *
\ext\com_dotnet\com_olechar.c, function php_com_string_to_olestring:
37d36
< uint unicode_strlen;
39,40c38,44
< unicode_strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ?
< 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), string, -1, NULL, 0);
---*/> if (string_len == -1) {
> /* determine required length for the buffer (includes NUL terminator)0);> string_len = MultiByteToWideChar(codepage, flags, string, -1, NULL,42,44c46,48> } else {
> /* allow room for NUL terminator */
> string_len++;
> }
< if (unicode_strlen > 0) {
< olestring = (OLECHAR*)safe_emalloc(sizeof(OLECHAR), unicode_strlen,
0);
< ok = MultiByteToWideChar(codepage, flags, string, -1, olestring,
unicode_srlen);
---olestring, string_len);> if (strlen > 0) {
> olestring = (OLECHAR*)safe_emalloc(sizeof(OLECHAR), string_len, 0);
> ok = MultiByteToWideChar(codepage, flags, string, string_len,
--
Edit bug report at [url]http://bugs.php.net/?id=40664&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40664&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40664&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40664&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40664&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40664&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40664&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40664&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40664&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40664&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40664&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40664&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40664&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40664&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40664&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40664&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40664&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40664&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40664&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40664&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40664&r=mysqlcfg[/url]
fjortiz at comunet dot es Guest
-
#39126 [NEW]: String->float->String conversion behavior
From: bobson at rpg dot pl Operating system: Linux PHP version: 5CVS-2006-10-11 (snap) PHP Bug Type: Unknown/Other Function... -
#25745 [Opn->Csd]: Character type functions fail on negative chars
ID: 25745 Updated by: moriyoshi@php.net Reported By: vesely at tana dot it -Status: Open +Status: ... -
#25745 [Asn->Fbk]: Character type functions fail on negative chars
ID: 25745 Updated by: moriyoshi@php.net Reported By: vesely at tana dot it -Status: Assigned +Status: Feedback Bug Type: ... -
#25745 [Opn->Asn]: Character type functions fail on negative chars
ID: 25745 Updated by: moriyoshi@php.net Reported By: vesely at tana dot it -Status: Open +Status: Assigned Bug Type: ... -
#25745 [NEW]: Character type functions fail on negative chars
From: vesely at tana dot it Operating system: PHP version: 4.3.2 PHP Bug Type: *Languages/Translation Bug description: ...



Reply With Quote

