Edit report at https://bugs.php.net/bug.php?id=79217&edit=1
ID: 79217
User updated by: steve dot lloyd at gmail dot com
Reported by: steve dot lloyd at gmail dot com
Summary: Last character of a UTF-8 string gets messed up
Status: Open
Type: Bug
Package: ODBC related
Operating System: Centos
PHP Version: 7.3.14
Block user comment: N
Private report: N
New Comment:
Interesing bit of information:
The field I am querying is set to nvarchar(25). If I cast it as nvarchar(50) it works.
test query:
----------
select cast(mtstb as nvarchar(50)) mtstb from sltschema.t141t
Results:
---------
Mtstb
å éè´/ä»åºè被å»ç»
å 任塿¸ å/BOMè被å»ç»
MPN:BOMæ¬å¤´å»ç»
gesp. für Besch./Lager
gesp. für Arb.plan/Stückl
Previous Comments:
------------------------------------------------------------------------
[2020-02-04 13:09:26] steve dot lloyd at gmail dot com
PDO has the same problem.
test script:
--------------------
try {
$pdo = new PDO("odbc:{$datasource}",$username, $password);
$query = "select * from sltschema.t141t";
$poo = $pdo->prepare($query);
$poo->execute();
$row = $poo->fetch(PDO::FETCH_ASSOC);
print_r($row);
}
catch (PDOException $e) {
echo "Connection failed : ". $e->getMessage();
}
Result:
---------------
Array
(
[MANDT] => 000
[SPRAS] => 1
[MMSTA] => 01
[MTSTB] => å éè´/ä»åºè被å»tc
[ZMODIFIEDTS] => 20200131152705439
[ZMODIFIEDTS_TEST] => 2020-01-31 15:27:05.4380000a
)
--------------------------
The bug you referred to seemed to say this was patched but it is still an issue in PHP 7.4. How do
I patch/resolve this issue?
------------------------------------------------------------------------
[2020-02-04 08:56:37] cmb@php.net
This seems to be related to bug #44278.
Can you try basically the same script with PDO_ODBC instead?
------------------------------------------------------------------------
[2020-02-03 22:06:52] steve dot lloyd at gmail dot com
Description:
------------
Last character of a UTF-8 string gets messed up. See stackoverflow URL in Test Script section. I
have tried this with multiple PHP versions. I have concluded it must be an issue with PHP ODBC
functions as it works fine in other languages (python, isql).
Test script:
---------------
https://stackoverflow.com/questions/59904479/last-character-issue-with-sap-hana-utf8-on-php
Expected result:
----------------
å éè´/ä»åºè被å»ç»
å 任塿¸ å/BOMè被å»ç»
MPN:BOMæ¬å¤´å»ç»
gesp. für Besch./Lager
gesp. für Arb.plan/Stückl
Actual result:
--------------
å éè´/ä»åºè被å»ad
å 任塿¸ å/BOMè被ader
MPN:BOMæ¬å¤´å»ç»
gesp. für Besch./Lager
gesp. für Arb.plan/Stüca
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79217&edit=1