ID: 38760
Updated by: [EMAIL PROTECTED]
Reported By: aireater at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: MSSQL related
Operating System: Windows 2003 Server
PHP Version: 5.1.6
New Comment:
What makes you think that this code should convert something to UCS-2?
What does it have to do with mbstring, which is even not mentioned in
this code?
Previous Comments:
------------------------------------------------------------------------
[2006-09-09 13:04:57] aireater at gmail dot com
This is a sample script to reproduce the issue. Create a table with a
"name" column of a varchar type only before testing. The string "DD"
means the string is consisted of multi-byte UTF-8 cahracters. Some are
inserted correctly, but most of time, inserted strings are not
correctly shown on the screen because they are not correctly inserted
in UCS-2. This script is for MS SQL Server 2005 Express.
<?php
$server = "localhost\sqlexpress";
$username = "username";
$password = "password";
$sqlconnect = mssql_connect($server, $username, $password);
$sqldb = mssql_select_db("testdb",$sqlconnect);
$str = 'DD';
$sqlquery = "insert into testtable (name) values('".$str."');";
$results = mssql_query($sqlquery);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<?php
$result = mssql_query("SELECT * FROM testtable");
while ($row=mssql_fetch_array($result)){
echo $row['name']."<br>\n";}
mssql_close($sqlconnect);
?>
------------------------------------------------------------------------
[2006-09-09 12:12:25] [EMAIL PROTECTED]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2006-09-09 12:04:30] aireater at gmail dot com
Set mb_internal_encoding to UTF-8, and send an INSERT statement, that
inserts a multi-byte string in UTF-8 to a varchar culumn, then an
inserted string get garbage. It's not converted to UCS-2 that MS SQL
Server supports to store an unicode string.
------------------------------------------------------------------------
[2006-09-09 10:39:29] [EMAIL PROTECTED]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2006-09-09 01:30:35] aireater at gmail dot com
Description:
------------
On PHP 5.1.6 Windows binary with php_mbstring and php_mssql.dll
enabled, it fails to convert multi-byte UTF-8 strings to UCS-2
srtings.
I've tried MS SQL Server 2005 Express and Standard but no success. On
Windows 2003 Server. I've also tried several ntwdblib.dll but in vain.
Expected result:
----------------
Should correctly convert multi-byte UTF-8 strings to UCS-2.
Actual result:
--------------
Most of single byte UTF-8 strings seem to be stored in the database but
most of multi-byte UTF-8 strings get garbage.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38760&edit=1