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

From: Date: Wed, 26 Jul 2023 18:31:42 +0000
Subject: Bug #80874 [Opn]: 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-245046@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 User updated 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: If you look at my initial report you will see that I have set all columns to NVARCHAR, so they should be able to hold UTF8 values. My PHP environment can handle UTF8 characters as I have exactly the same table and data in a MySQ:L, PostgreSQL, Oracle and SL Server database, and they work as expected. When I view the contents of that table using the Eclipse IDE all the currency symbols are shown in the correct UTF8 characters. I have CHAR_AS_UTF8=TRUE in my ODBC settings, and I am not aware of any other settings to enable UTF8 characters. I never get the change to obtain a record and manually convert the characters to UTF8 as HANA simply will not return a row containing UTF8 characters. None of your suggestions address my problem. Previous Comments: ------------------------------------------------------------------------ [2023-07-25 06:45:10] julia788maxwell at gmail dot com The issue you are facing with the missing rows in the result set might be related to the encoding used for the currency symbols in the SAP HANA database and how it is handled in your PHP program. SAP HANA uses Unicode for character data, and it's important to ensure that the encoding is correctly handled in your PHP environment. To resolve the problem, try the following: Ensure that your PHP environment is properly configured to handle Unicode characters. Check that your PHP installation has the necessary extensions (e.g., mbstring) and is set to use UTF-8 encoding. (https://github.com)(https://www.ballsportsgames.com/) Update your connection settings to specify UTF-8 encoding for the ODBC connection: $conn = odbc_connect("Driver=$driver;ServerNode=$server;charset=UTF-8",$user,$pswd) OR die('Connection to DB via ODBC failed'); Check the data stored in the SAP HANA database table to ensure that the currency symbols are stored as valid Unicode characters. Update your SAP HANA database connection settings if necessary to ensure that it handles Unicode data correctly. Consider using the odbc_fetch_row function instead of odbc_fetch_array to fetch rows one by one and then manually convert the currency symbol to its UTF-8 representation in PHP if needed. By following these steps, you should be able to retrieve the currency symbols correctly from the SAP HANA database and display them in your PHP program. ------------------------------------------------------------------------ [2021-09-06 11:58:55] cmb@php.net > 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. Ah, I see. The basic problem is that PHP has no notion of the charset encoding of strings. Thus, it treats all strings as byte sequences. Therefore, we can't do any automatic conversion to UCS-2 and use SQLExecDirectW(). Well, actually we could, at least on Windows, where PHP 7.1.0 introduced UTF-8 support for file paths, and the respective framework (sapi_windows_cp_get|set). However, automatically doing the conversion would almost certainly break existing code for many other ODBC drivers (which do not automatically convert to UCS-2), so we would need to make that optional, and an INI setting might not be a good solution. Also, what to do for non Windows systems is unclear. Anyhow, this would be more like a new feature, and as such can't target any of the stable branches (PHP 7.4, PHP 8.0). ------------------------------------------------------------------------ [2021-09-06 10:24:44] tony at tonymarston dot net No, I have not found a workaround for this problem. This means that I cannot use SAP HANA with my multi-currency ERP application. ------------------------------------------------------------------------ [2021-09-06 09:35:18] jeremy dot galouye at gmail dot com Hello, I had the same issue have you found a workaround solution ? Thanks ------------------------------------------------------------------------ [2021-06-05 08:52:53] tony at tonymarston dot net 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 ------------------------------------------------------------------------ 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

« previous php.bugs (#245046) next »