places: add explicit convert to utf-8

pull/953/head
Varun Patil 2023-12-02 11:27:08 -08:00
parent b30786ca0c
commit ac9ce852bb
1 changed files with 15 additions and 2 deletions

View File

@ -273,9 +273,22 @@ class Places
// Extract data // Extract data
$osmId = $data['osm_id']; $osmId = $data['osm_id'];
$adminLevel = $data['admin_level']; $adminLevel = $data['admin_level'];
$name = $data['name'];
$boundaries = $data['geometry']; $boundaries = $data['geometry'];
$otherNames = json_encode($data['other_names'] ?? []);
/** @var string $name */
$name = $data['name'];
/** @var array<string, string> $otherNames */
$otherNames = $data['other_names'];
// Explicitly convert all names to UTF-8
$name = mb_convert_encoding($name, 'UTF-8');
$otherNames = [];
foreach (($data['other_names'] ?? []) as $lang => $val) {
$otherNames[$lang] = mb_convert_encoding($val, 'UTF-8');
}
$otherNames = json_encode($otherNames);
// Skip some places // Skip some places
if ($adminLevel > -2 && ($adminLevel <= 1 || $adminLevel >= 10)) { if ($adminLevel > -2 && ($adminLevel <= 1 || $adminLevel >= 10)) {