moodle-fileconverter_librelambda
moodle-fileconverter_librelambda copied to clipboard
Wrong conversion of SJIS-encoded text files
Hi
Thanks for all the good work you do with this plugin
I've been trying to convert text (.txt) files encoded in SJIS and the conversion process doesn't report any problem but the result is incorrect
This is because LibreOffice doesn't support the conversion of SJIS files, but it can be solved from the PHP side by converting the contents of the file manually to UTF-8
$formats = ['ASCII', 'JIS', 'UTF-8', 'EUCJP-WIN', 'EUC-JP', 'SJIS-WIN', 'SJIS'];
$enc = mb_detect_encoding($content, $formats);
$utf8_content = mb_convert_encoding($content, 'UTF-8', $enc);
This allows LibreOffice to work as expected
test_sjis_short.txt this is a file encoded in SJIS, for testing purposes
Thanks for your help