[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: New to LUA, trying to read from a file
- From: David Given <dg@...>
- Date: Wed, 08 Oct 2008 12:58:06 +0100
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
- References:
- New to LUA, trying to read from a file, Brian Sanders
- Re: New to LUA, trying to read from a file, Tim Channon
- Re: New to LUA, trying to read from a file, Brian Sanders
- Re: New to LUA, trying to read from a file, Klaus Ripke
- Re: New to LUA, trying to read from a file, Klaus Ripke
- Re: New to LUA, trying to read from a file, Brian Sanders