lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Brian Sanders wrote:
> Hmm... so if it is in either UTF-16 or UCS-2 with BOM... is there any
> way for me to use these log files with a LUA script?  I guess it is good
> to know that I did understand the LUA tutorials, it was my input file I
> was not looking closely enough at.

You need to convert it somehow into UTF-8. There are a number of Lua
addons for doing this sort of transcoding, but if you've got Cygwin,
it's probably easier just to use the following command line:

iconv -f utf-16 -t utf-8 fnord.log > fnord.txt

...then open 'fnord.txt'.

You may even be able to do this:

local fp = io.popen("iconv -f utf-16 -t utf-8 fnord.log")
local text = fp:read("*all")

...but I forget whether that works on Windows.

(This whole problem is due to Windows having a rather different idea of
what 'plain text' means to the rest of the world; see
http://en.wikipedia.org/wiki/Bush_hid_the_facts for a rather amusing
consequence...)

-- 
David Given
dg@cowlark.com