From b5024731a4277e743e16d3db8b12c85f1570f77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Sat, 18 May 2024 22:08:48 +0200 Subject: [PATCH] Utf8 encode (#1225) * provider: IP2LocationBinary: replace utf8_encode with mb_convert_encoding * provider: MaxMindBinary: replace utf8_encode with mb_convert_encoding --- src/Provider/IP2LocationBinary/IP2LocationBinary.php | 4 ++-- src/Provider/IP2LocationBinary/composer.json | 3 ++- src/Provider/MaxMindBinary/MaxMindBinary.php | 4 ++-- src/Provider/MaxMindBinary/composer.json | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Provider/IP2LocationBinary/IP2LocationBinary.php b/src/Provider/IP2LocationBinary/IP2LocationBinary.php index 33755ff43..1080b3582 100644 --- a/src/Provider/IP2LocationBinary/IP2LocationBinary.php +++ b/src/Provider/IP2LocationBinary/IP2LocationBinary.php @@ -81,9 +81,9 @@ public function geocodeQuery(GeocodeQuery $query): Collection Address::createFromArray([ 'providedBy' => $this->getName(), 'countryCode' => $records['countryCode'], - 'country' => null === $records['countryName'] ? null : utf8_encode($records['countryName']), + 'country' => null === $records['countryName'] ? null : mb_convert_encoding($records['countryName'], 'UTF-8', 'ISO-8859-1'), 'adminLevels' => $adminLevels, - 'locality' => null === $records['cityName'] ? null : utf8_encode($records['cityName']), + 'locality' => null === $records['cityName'] ? null : mb_convert_encoding($records['cityName'], 'UTF-8', 'ISO-8859-1'), 'latitude' => $records['latitude'], 'longitude' => $records['longitude'], 'postalCode' => $records['zipCode'], diff --git a/src/Provider/IP2LocationBinary/composer.json b/src/Provider/IP2LocationBinary/composer.json index 7008bedeb..ae178a4fa 100644 --- a/src/Provider/IP2LocationBinary/composer.json +++ b/src/Provider/IP2LocationBinary/composer.json @@ -14,6 +14,7 @@ "require": { "php": "^8.0", "ip2location/ip2location-php": "^8.1.1", + "symfony/polyfill-mbstring": "^1.0", "willdurand/geocoder": "^4.0" }, "provide": { @@ -42,4 +43,4 @@ "test": "vendor/bin/phpunit", "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" } -} \ No newline at end of file +} diff --git a/src/Provider/MaxMindBinary/MaxMindBinary.php b/src/Provider/MaxMindBinary/MaxMindBinary.php index 560ec7467..3e1f8a856 100644 --- a/src/Provider/MaxMindBinary/MaxMindBinary.php +++ b/src/Provider/MaxMindBinary/MaxMindBinary.php @@ -92,9 +92,9 @@ public function geocodeQuery(GeocodeQuery $query): Collection Address::createFromArray([ 'providedBy' => $this->getName(), 'countryCode' => $geoIpRecord->country_code, - 'country' => null === $geoIpRecord->country_name ? null : utf8_encode($geoIpRecord->country_name), + 'country' => null === $geoIpRecord->country_name ? null : mb_convert_encoding($geoIpRecord->country_name, 'UTF-8', 'ISO-8859-1'), 'adminLevels' => $adminLevels, - 'locality' => null === $geoIpRecord->city ? null : utf8_encode($geoIpRecord->city), + 'locality' => null === $geoIpRecord->city ? null : mb_convert_encoding($geoIpRecord->city, 'UTF-8', 'ISO-8859-1'), 'latitude' => $geoIpRecord->latitude, 'longitude' => $geoIpRecord->longitude, 'postalCode' => $geoIpRecord->postal_code, diff --git a/src/Provider/MaxMindBinary/composer.json b/src/Provider/MaxMindBinary/composer.json index bf2b69d90..e22175867 100644 --- a/src/Provider/MaxMindBinary/composer.json +++ b/src/Provider/MaxMindBinary/composer.json @@ -14,6 +14,7 @@ "require": { "php": "^8.0", "geoip/geoip": "^1.17", + "symfony/polyfill-mbstring": "^1.0", "willdurand/geocoder": "^4.0" }, "provide": { @@ -42,4 +43,4 @@ "test": "vendor/bin/phpunit", "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" } -} \ No newline at end of file +}