Writing to file, UTF-8 - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Writing to file, UTF-8 (/showthread.php?tid=2954) |
Writing to file, UTF-8 - Trond Hoyem - 03.11.2020 Hi I have made this script that is testing my installation and writing the result to a file and then sends it to my email. The only problem I still have is that the messages written to the report contains some Nordic characters, and that returns some ugly results like "PÃ¥drag ble ikke endret under varmetest". Is there any way to set the character set to the file when writing to it? Creating the file itself: Code: errorFile = string.format('Feilmeldinger_%s.csv', os.date('%d-%m-%Y',log_start)) The code for adding a line to the table is: Code: table.insert(errorBuffer, addr.name .. '; Gikk ikke til 100% pådrag.') Writing to file; Code: result, err = io.writefile ('/home/ftp/' .. errorFile, table.concat(errorBuffer, '\r\n')) Is there anywhere in those where I can add the character set? RE: Writing to file, UTF-8 - admin - 03.11.2020 You can add UTF-8 byte order mark to your CSV like this: Code: bom = string.char(0xEF, 0xBB, 0xBF) RE: Writing to file, UTF-8 - Trond Hoyem - 03.11.2020 (03.11.2020, 11:05)admin Wrote: You can add UTF-8 byte order mark to your CSV like this: As always, the help in here is fast and on the spot! Thx again! |