I have some CSV files need to convert from shift-jis to utf-8.
Here is my code in PHP, which is successful transcode to readable text.
$str = utf8_decode($str);
$str = iconv('shift-jis', 'utf-8'. '//TRANSLIT', $str);
echo $str;
My problem is how to do same thing in Python.
I don't know PHP, but does this work :
Also I assume the CSV content is from a file. There are a few options for opening a file in python.
would be the first and you would get data as it is
would be the default file opening
Also I tried on my computed with a shift-js text and the following code worked :
result was the following in UTF-8 (without any errors)
Ok I validate my solution :)
The first char is indeed the good character: "\xe3\x81\xa6" means "E3 81 A6" It gives the correct result.
You can try yourself at this URL