Quy Nguyen Vu
Quy Nguyen Vu

Reputation: 181

PHP convert encoding with Shift_JIS

I have a text file. It contains "砡" character and its encoding is Shift-JIS.

I using function file_get_contents() in PHP (Laravel) to read this file, then response in json for client.

$file = file_get_contents("/path/to/file/text");
$file = iconv("SJIS", "UTF-8//IGNORE", $file);
return response()->json(['content' => $file]);

However, this charater "砡" doesn't correctly display, it show to "x".

How do I fix it ?

Upvotes: 2

Views: 3598

Answers (1)

Will
Will

Reputation: 53

Try "SJIS-win" instead of "SJIS".

Upvotes: 3

Related Questions