Archive: Reading Unicode Lines from External file


Reading Unicode Lines from External file
Hello fellow NSIS-ers,

I'm in need of a solution for a dilemma that I'm currently having. I've got an output log (see attachments) that is encoded in UTF-8 without BOM and I need to read it into the installer on runtime.

Here's a snippet of the code.

FileOpen $R9 "$EXEDIR\output.log" r

StrCpy $1 ""

read:
FileReadUTF16LE $R9 $0
StrCpy $1 "$1$0"
IfErrors done read
done:

MessageBox MB_OK $1

FileClose $R9


The problem I'm having is that FileRead reads as ANSI and therefore the characters come out strange, where as FileReadUTF16LE gives me a garbled heap of junk when I run it.

Manually converting the file in Notepad++ to UTF16LE and then reading it from there seems to work fine, but I need something that can do it programmatically.

The only solutions I can think of, is either having a FileRead that does UTF8 or some way to convert my log to UTF16LE while keeping the contents the same (I've tried a few converters here, no luck whatsover)

Any thought/ insight into this? I'm using Unicode NSIS v2.46.5 btw

Hmmm first solution which same to my mind is to write C plug-in for converting file to UTF16LE.


I actually thought of doing that, and I don't mind it as much, but I'd rather have something contained more in NSIS.