2

I would like to convert data from SQL Server (ASCII) to UTF-8.

When I use the query :

SELECT SERVERPROPERTY('Collation')

The result is 'French_CI_AS' (So, ASCII)

When I use DBAL from Symfony to get users from a remote database, and then, show them, it appears that the accents looks like that :

Ang�lina

I tried :

utf8_encode($value)

but it's only for ISO-8859-1...

So I tried :

iconv("French_CI_AS", "UTF-8", $value)

Or :

iconv("ASCII", "UTF-8", $value)

but it doesn't seems to work...

My meta template is :

<meta charset="utf-8" />

So, any idea to convert the user names from ASCII to UTF-8 ?

Florian Doyen
  • 160
  • 2
  • 15

1 Answers1

2

ASCII cannot store French, as far as I know. MSDN suggests that French_CI_AS uses Windows-1252 as encoding. Try that instead.

In any case, your DB library should take care of that automatically. You've probably failed to provide the connection encoding.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • using iconv("WINDOWS-1252", "UTF-8", $value); or mb_convert_encoding($value, "UTF-8", "WINDOWS-1252"); didn't change anything... Or maybe I falied something ? I use Symfony and a config.yml file but if I write charset: UTF8 it doesn't change anything. I'm on a Debian, I use a MS SQL driver for Linux to connect to the remote database... – Florian Doyen Aug 07 '14 at 11:56
  • 1
    Please check [Getting data with UTF-8 charset from MSSQL server using PHP FreeTDS extension](http://stackoverflow.com/questions/13377812/getting-data-with-utf-8-charset-from-mssql-server-using-php-freetds-extension) – Álvaro González Aug 07 '14 at 12:09