|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesExtra_allocation_for_transforming_character_code (last revision 2016-01-25 01:45 UTC by ta_nakagawa at ysco dot net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-02-23 14:04 UTC] ab@php.net
-Status: Open
+Status: Feedback
[2016-02-23 14:04 UTC] ab@php.net
[2016-02-29 01:26 UTC] ta_nakagawa at ysco dot net
-Status: Feedback
+Status: Open
[2016-02-29 01:26 UTC] ta_nakagawa at ysco dot net
[2016-03-01 14:34 UTC] ab@php.net
-Status: Open
+Status: Verified
[2016-03-01 14:34 UTC] ab@php.net
[2016-03-01 14:34 UTC] ab@php.net
-Status: Verified
+Status: Feedback
[2016-03-01 14:34 UTC] ab@php.net
[2016-03-12 12:47 UTC] ta_nakagawa at ysco dot net
-Status: Feedback
+Status: Open
[2016-03-12 12:47 UTC] ta_nakagawa at ysco dot net
[2016-04-18 15:36 UTC] ta_nakagawa at ysco dot net
[2020-10-05 12:47 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2020-10-05 12:47 UTC] cmb@php.net
[2020-10-06 03:52 UTC] ta_nakagawa at ysco dot net
-Status: Feedback
+Status: Assigned
[2020-10-06 03:52 UTC] ta_nakagawa at ysco dot net
[2020-10-06 07:35 UTC] cmb@php.net
-Status: Assigned
+Status: Open
-Assigned To: cmb
+Assigned To:
[2020-10-06 07:35 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 02:00:01 2025 UTC |
Description: ------------ When the query returns the UTF-8 multibyte character (such as Japanese characters) from a AS/400 EBCDIC data field via ODBC, the last some characters is terminated in the ODBC module of PHP. The conversion from EBCDIC to UTF-8 increases the size of the characters. The data size of UTF-8 becomes 2.5 times in the case of the size maximizing. ODBC driver (DB2CLI or IBM i access for windows) converts to the UTF-8 characters correctly, but the PHP does not have the buffer storing the incremental size for the conversion. As a result the last some characters is dropped. For example, in AS/400 the data field by 20 bytes can store 9 EBCDIC double byte characters (20 bytes) such as Japanese character. It becomes 27 bytes in UTF-8. When PHP receives the data from the driver, the size of the variable assigned the data is not sufficient. So the last 3 characters corresponding to 7 bytes are lost. This problem can be avoid by extra allocation to the variable of the characters within the function "odbc_bindcols" in the source "\ext\odbc\php_odbc.c" It needs to remove the conditional statement for extra allocation of character. We hope that the problem in an appropriate manner is resolved. Thank you for your consideration. diff -u ext/odbc/php_odbc.c.orig ext/odbc/php_odbc.c --- ext/odbc/php_odbc.c.orig 2016-01-06 07:14:48.000000000 +0900 +++ ext/odbc/php_odbc.c 2016-01-21 22:16:59.767514900 +0900 @@ -1020,10 +1020,9 @@ displaysize += 3; } - if (charextraalloc) { - /* Since we don't know the exact # of bytes, allocate extra */ - displaysize *= 4; - } + /* Since we don't know the exact # of bytes, allocate extra */ + displaysize *= 4; + result->values[i].value = (char *)emalloc(displaysize + 1); rc = SQLBindCol(result->stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, result->values[i].value, displaysize + 1, &result->values[i].vallen); Test script: --------------- $conn = odbc_connect("MyDSN", "MyUser", "MyPWD"); $query = 'SELECT TKBANG,TKNAKJ FROM TOKMSP'; $stmt = odbc_prepare($conn, $query); $ret = odbc_execute($stmt); while($record = odbc_fetch_array($ret) ) print_r($record); odbc_close($conn); Expected result: ---------------- Array ( [TKBANG] => 00121 [TKNAKJ] => たちつてとなにぬね ) The character of [TKNAKJ] is Japanese. The data has already been inserted to the column. Actual result: -------------- Array ( [TKBANG] => 00121 [TKNAKJ] => たちつてとな ) The last 3 characters are terminated.