I want to convert my query results from a database, which is SQL_ASCII database encoded, to UTF-8.

$result = $query->execute;
$converted_data = array();
foreach($result as $record){
    $converted_data[count($converted_data)] = drupal_convert_to_utf8($record->name, 'sql-ascii');

I used drupal_convert_to_utf8 but it returns blank all the time. I was confused if sql-ascii should be the second parameter of drupal_convert_to_utf8. The database encoding, where the query results is fetched, is SQL_ASCII in postgres.


According to the official documentation, It

Requires the iconv, GNU recode or mbstring PHP extension.

What are they? Am I going to install/include it or what?


Go to /admin/reports/status and take a look at your unicode library. If you don't have multibyte support, install it: http://php.net/manual/en/mbstring.installation.php

I.e. for ubuntu like systems it's sudo apt-get install php7.0-mbstring for PHP7.


You could try 'auto' instead of 'sql_ascii', and btw., you can skip the count() call and can just write $converted_data[] = drupal_...


  • I found "Unicode library PHP Mbstring Extension" in admin/reports. How will I know if I have to install it? – user46175 Jul 22 '16 at 9:01
  • 1
    Go to /admin/reports/status/php and search for "Multibyte Support", should be "enabled" - then we need to search for other problems. – Rainer Feike Jul 22 '16 at 9:53
  • 'extension=php_mbstring.dll' in php.ini was already enabled. I tried finding php_mbstring.dll at php/ext folder in windows and it does exist. But my problem still occurs. – user46175 Jul 25 '16 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy