UTF-8 변환(실패해도 빈문자/대체로 처리) $out = @iconv('EUC-KR', 'UTF-8//IGNORE', $s); // iconv가 false면 mb_convert로 한번 더(가능할 때) if ($out === false) { $out = function_exists('mb_convert_encoding') ? @mb_convert_encoding($s, 'UTF-8', 'EUC-KR') : ''; } // 그래도 UTF-8이 아니면 마지막으로 invalid byte 제거 if ($out === false || $out === '') $out = ''; if (function_exists('mb_check_encoding') && !mb_check_encoding($out, 'UTF-8')) { $out = @iconv('UTF-8', 'UTF-8//IGNORE', $out) ?: ''; } return $out; } public function mapToUtf8(array $arr): array { foreach ($arr as $k => $v) { if (is_string($v) && $v !== '') { $arr[$k] = $this->toUtf8($v); } } return $arr; } }