Initial commit BIJ CI4
This commit is contained in:
33
app/Libraries/LegacyUtf8Encoder.php
Normal file
33
app/Libraries/LegacyUtf8Encoder.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
/**
|
||||
* Replikasi perilaku utf8ize() dari CI3 Json controller (string ISO-8859-1 → UTF-8).
|
||||
* Catatan: password/token tetap legacy (MD5 / token kolom) — lihat docs/migration/risks.md.
|
||||
*/
|
||||
class LegacyUtf8Encoder
|
||||
{
|
||||
/**
|
||||
* @param mixed $d
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function utf8ize($d)
|
||||
{
|
||||
if (is_array($d)) {
|
||||
foreach ($d as $k => $v) {
|
||||
$d[$k] = self::utf8ize($v);
|
||||
}
|
||||
} elseif (is_string($d)) {
|
||||
// Samakan dengan CI3 json.php utf8_encode() (Latin-1 → UTF-8).
|
||||
if (function_exists('utf8_encode')) {
|
||||
return @utf8_encode($d);
|
||||
}
|
||||
|
||||
return mb_convert_encoding($d, 'UTF-8', 'ISO-8859-1');
|
||||
}
|
||||
|
||||
return $d;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user