Bug #80874 [Com]: odbc_fetch_array() will not fetch a row containing a UTF-8 currency code symbol

From: Date: Sat, 05 Jun 2021 08:52:53 +0000
Subject: Bug #80874 [Com]: odbc_fetch_array() will not fetch a row containing a UTF-8 currency code symbol
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234218@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80874&edit=1

 ID:                 80874
 Comment by:         tony at tonymarston dot net
 Reported by:        tony at tonymarston dot net
 Summary:            odbc_fetch_array() will not fetch a row containing a
                     UTF-8 currency code symbol
 Status:             Open
 Type:               Bug
 Package:            ODBC related
 Operating System:   Windows 10
 PHP Version:        7.4.16
 Block user comment: N
 Private report:     N

 New Comment:

A developer at SAP has been investigating this problem and has discovered that the PHP odbc module
is not formatting the UCS-2 text correctly on Windows for the HANA ODBC driver. You can read his
full response at https://answers.sap.com/questions/13231775/hana-utf8-characters-being-garbled-when-using-the.html?childToView=13407210


Previous Comments:
------------------------------------------------------------------------
[2021-04-21 14:38:30] tony at tonymarston dot net

I do not know which driver is fault, so I have also reported this bug to the SAP HANA community at
https://answers.sap.com/questions/13322291/odbc-fetch-array-will-not-fetch-a-row-containing-a.html,
but as they have not tried accessing their database via PHP running on Windows they are unable to
reproduce this fault and there remain clueless.

I do not have the resources to try the same code using PHP on Linux, so I don't know if that
ODBC driver is any better. All I can say at the moment is that trying to access a SAP HANA database
from PHP is not a viable proposition.

------------------------------------------------------------------------
[2021-04-21 12:35:19] cmb@php.net

> These tests clearly show that the HANA ODBC driver mangles UTF8
> values both when written and when read.

If it is the driver, there is not we can do about that, can't we?

------------------------------------------------------------------------
[2021-03-20 16:41:27] tony at tonymarston dot net

I have tried using the PDO ODBC driver both with and without the PDO::ODBC_ATTR_ASSUME_UTF8 option
with mixed results. I have also run tests by accessing the same data in a SQL Server database via
the PDO ODBC driver as a comparison.

I have captured the output from various tests which you can download from http://www.tonymarston.net/test-odbc-utf8.zip

TEST-1 uses the ODBC driver using data which was inserted using JDBC (the Eclipse plugin)

TEST-2 uses the ODBC driver using data which was inserted using PHP and the ODBC driver

TEST-3 uses the PDO-ODBC driver without the UTF8 attribute using data which was inserted using JDBC

TEST-4 uses the PDO-ODBC driver without the UTF8 attribute using data which was inserted using PHP

TEST-5 uses the PDO-ODBC driver with the UTF8 attribute using data which was inserted using JDBC

TEST-6 uses the PDO-ODBC driver with the UTF8 attribute using data which was inserted using PHP

These tests clearly show that the HANA ODBC driver mangles UTF8 values both when written and when
read.

The test using the PDO-ODBC driver with the UTF8 attribute turned ON produced the worst results as
it totally mangled all the non-UTF8 characters.

------------------------------------------------------------------------
[2021-03-19 13:19:31] cmb@php.net

> Byte Order Marks should *NEVER* be added to database columns, […]

I suggest you tell that whoever is responsible for inserting the
BOM.  It certainly is not PHP.  It *might* be the ODBC driver.

Anyhow, if PDO_ODBC with PDO::ODBC_ATTR_ASSUME_UTF8 yields the
same broken results, I don't think this is a PHP issue.  It might
be an issue with the driver, or some configuration issue.  I
wouldn't know where to look further.  Maybe some SAP HANA ODBC
driver support channel can be more helpful.

------------------------------------------------------------------------
[2021-03-18 18:27:10] tony at tonymarston dot net

> 'EFBBBF3F' in hexadecimal is a UTF-8 BOM followed by a question mark.

Byte Order Marks should *NEVER* be added to database columns, only files.

> Did you try with CHAR_AS_UTF8=FALSE?

Yes, but the results were the same.

> would this work with PDO_ODBC?

Accessing the SAP HANA database had the same result - it stopped fetching rows after the 2nd row.

Access the SQL Server database had a different result - the symbol for 'THB' was returned
as '?' on its own without the UTF-8 BOM.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=80874


--
Edit this bug report at https://bugs.php.net/bug.php?id=80874&edit=1


Thread (17 messages)

« previous php.bugs (#234218) next »