Bug #62426 [Com]: mysqli_fetch_field_direct returns incorrect length on UTF8 fields

From: Date: Mon, 06 Jul 2015 11:53:03 +0000
Subject: Bug #62426 [Com]: mysqli_fetch_field_direct returns incorrect length on UTF8 fields
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194153@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62426&edit=1 ID: 62426 Comment by: cweiske@php.net Reported by: robert dot butler at hoa-management dot com Summary: mysqli_fetch_field_direct returns incorrect length on UTF8 fields Status: Not a bug Type: Bug Package: MySQLi related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: PHP 5.2 actually returned the correct length, while 5.3, 5.4, 5.5 and 5.6 return the triple size. Previous Comments: ------------------------------------------------------------------------ [2012-07-02 13:28:58] uw@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Returns bytes ------------------------------------------------------------------------ [2012-06-26 21:48:24] robert dot butler at hoa-management dot com Description: ------------ When using UTF8 in the database (mySQL 5.5.24-0ubuntu0.12.04.1), fields defined as a certain length aren't returned as the correct length by mysqli_fetch_field_direct. IOW, a char(32) field is shown as actually being 96 chars long because it's 32 * 3 (3 bytes per char instead of one). The older mysql_field_len correctly reports the length. Test script: --------------- // Assuming a single table with a single field 'test' defined as char(32) // and UTF-8 charset. $connection = = mysqli_connect ('localhost', 'user', 'password'); $query = "SELECT test FROM test_table LIMIT 1"; $result = mysqli_query ($connection, $query); $field_info = mysqli_fetch_field_direct ($result, 0); echo $field_info -> length; Actual result: -------------- Returns 96; should be 32. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62426&edit=1

« previous php.bugs (#194153) next »