Re: GeoIP Character Encoding
| From: | Nisse Engström | Date: | Wed, 29 Jul 2009 08:34:53 +0000 |
| Subject: | Re: GeoIP Character Encoding | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295997@lists.php.net to get a copy of this message | ||
On Tue, 28 Jul 2009 18:10:33 -0400, APseudoUtopia wrote:
> I'm using the PECL GeoIP module on php 5.2.10. When I look up an IP
> address, the geoip_record_by_name() function is giving me a string
> that contains "special" characters, such as the following:
The PECL GeoIP page links to <http://www.maxmind.com/>,
and a
search for "charset" reveals the following:
<http://forum.maxmind.com/viewtopic.php?p=2031&highlight=>
<quote>
the binary database return the cityname in iso-8859-1 by default.
I guess your output is in a different charset.
The CAPI based wrappers have a set_charset method.
If you use any other API, use the language charset encoding to
transform iso-8859-1 into the desired output format.
for php you might use:
Code:
$city = mb_convert_encoding( $old_city, 'UTF-8', 'ISO-8859-1');
or
Code:
$city = utf8_encode ( $oold_city )
</quote>
/Nisse