moodle-fileconverter_librelambda icon indicating copy to clipboard operation
moodle-fileconverter_librelambda copied to clipboard

Wrong conversion of SJIS-encoded text files

Open rikardow opened this issue 1 year ago • 0 comments

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

image

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

rikardow avatar Jan 25 '24 18:01 rikardow