PHP: problems converting the "" character from ISO-8859-1 to UTF-8

I'm having trouble using PHP to convert the contents of an ISO-8859-1 database to UTF-8. I am testing the following code:

// Connect to a latin1 charset database 
// and retrieve "Georgia O’Keeffe", which contains a "’" character
$connection = mysql_connect('*****', '*****', '*****');
mysql_select_db('*****', $connection);
mysql_set_charset('latin1', $connection);
$result = mysql_query('SELECT notes FROM categories WHERE id = 16', $connection);
$latin1Str = mysql_result($result, 0);
$latin1Str = substr($latin1Str, strpos($latin1Str, 'Georgia'), 16);

// Try to convert it to UTF-8
$utf8Str = iconv('ISO-8859-1', 'UTF-8', $latin1Str);

// Output both
var_dump($latin1Str);
var_dump($utf8Str);

When I run this in the original Firefox view, make sure the Firefox setting is set to “Western (ISO-8859-1),” I get the following:

asd

So far so good. The first conclusion contains this strange quote, and I see it correctly because it is in ISO-8859-1 and Firefox.

After changing the Firefox encoding setting to "UTF-8", it looks like this:

asd

Where was the quote? Could it be iconv()converted to UTF-8?

+5
2

U + 2019 ISO-8859-1. windows-1252, 0x92. ISO-8859-1 0x92 C1 " 2" .

Windows-1252 ISO-8859-1. - MIME- ISO-8859-1 Windows-1252 , ​​ , ISO-8859-1 .

, , . "ISO-8859-1" "windows-1252".

+14

, , charset utf-8:

// Opens a connection to a MySQL server
$connection = mysql_connect ($server, $username, $password);
$charset = mysql_client_encoding($connection);
$flagChange = mysql_set_charset('utf8', $connection);
echo "The character set is: $charset</br>mysql_set_charset result:$flagChange</br>";
0

All Articles