Edit report at https://bugs.php.net/bug.php?id=80869&edit=1
ID: 80869
Comment by: sergiopaternoster73 at gmail dot com
Reported by: sergiopaternoster73 at gmail dot com
Summary: SQL Server: Read NVARCHAR Unicode
Status: Open
Type: Bug
Package: PDO ODBC
Operating System: Ubuntu 18.04 Server
PHP Version: 8.0.3
Block user comment: N
Private report: N
New Comment:
I tested it on Windows (PHP 7.2.5 and PHP 8.0.3).
SELECT NAME FROM TABLE; (NAME is defined as NVARCHAR(200))
They both work *ONLY* if I set the PDO::ODBC_ATTR_ASSUME_UTF8 => true as option. Otherwise, I
will always get an ASCII when I read an NVARCHAR() column.
How come do I need to specify PDO::ODBC_ATTR_ASSUME_UTF8 ? The result is supposed to be a UTF-8.
Thanks for your help
Previous Comments:
------------------------------------------------------------------------
[2021-03-16 12:26:14] sergiopaternoster73 at gmail dot com
These are the new traces with FreeTDS 1.2 (from 0.9 before).
Now they look more consistent than before. So why the problem persists?
php 7 trace:
https://gist.github.com/capsandiego/18b2cbb5f6f3e518f508c9b16335b513
php 8 trace:
https://gist.github.com/capsandiego/d51367c34d506d37aa6c62b46d71e1b3
------------------------------------------------------------------------
[2021-03-16 12:08:04] sergiopaternoster73 at gmail dot com
I have recompiled php 8 with the latest version of FreeTDS but the problem persists. Do you have any
other suggestions to query SQL Server from PHP on Linux and preserve UTF-8 chars?
------------------------------------------------------------------------
[2021-03-16 10:14:48] sergiopaternoster73 at gmail dot com
Quick question.
I compile php with --with-pdo_odbc=unixODBC,/usr and --with-unixODBC=/usr
Pardon my ignorance again, shall we focus on FreeTDS or unixODBC to look for a solution?
------------------------------------------------------------------------
[2021-03-16 07:22:31] sergiopaternoster73 at gmail dot com
Thanks for checking. It looks the opposite to me, am I wrong?
PHP 8 uses ISO-8859-1
iconv.c:330:tds_iconv_open(0x3a6c880, ISO-8859-1)
while PHP 7.4 UTF-8
iconv.c:330:tds_iconv_open(0x2754e40, UTF-8)
I will anyway try to compile the latest version of FreeTDS to see if this will improve.
------------------------------------------------------------------------
[2021-03-15 20:53:37] cmb@php.net
Thank you for the traces! These are actually quite helpful,
because the first lines show a difference in the setup or build
(7.4 uses ISO-8859-1, while 8.0 uses UTF-8). I don't know
FreeTDS, so I have no idea why they are using different client
charsets. Consider to ask on a FreeTDS support channel, too.
------------------------------------------------------------------------
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=80869
--
Edit this bug report at https://bugs.php.net/bug.php?id=80869&edit=1