Skip to content

Commit

Permalink
Utf8 encode (#1225)
Browse files Browse the repository at this point in the history
* provider: IP2LocationBinary: replace utf8_encode with mb_convert_encoding

* provider: MaxMindBinary: replace utf8_encode with mb_convert_encoding
  • Loading branch information
kornrunner committed May 18, 2024
1 parent cf00101 commit b502473
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Provider/IP2LocationBinary/IP2LocationBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
3 changes: 2 additions & 1 deletion src/Provider/IP2LocationBinary/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"require": {
"php": "^8.0",
"ip2location/ip2location-php": "^8.1.1",
"symfony/polyfill-mbstring": "^1.0",
"willdurand/geocoder": "^4.0"
},
"provide": {
Expand Down Expand Up @@ -42,4 +43,4 @@
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
}
}
}
4 changes: 2 additions & 2 deletions src/Provider/MaxMindBinary/MaxMindBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/Provider/MaxMindBinary/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"require": {
"php": "^8.0",
"geoip/geoip": "^1.17",
"symfony/polyfill-mbstring": "^1.0",
"willdurand/geocoder": "^4.0"
},
"provide": {
Expand Down Expand Up @@ -42,4 +43,4 @@
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
}
}
}

0 comments on commit b502473

Please sign in to comment.