lua-users home
lua-l archive

Re: Is it possible to add utf-8 lua source file support in lua 5.2?

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


On 9/27/2010 3:20 AM, Duncan Cross wrote:
To be honest, it seems only fair to me, since Lua's standard script
file loader already supports ignoring the first line if it begins with
a shebang. This sets a precedent that it is appropriate for the loader
to ignore common, OS-specific pecularities at the beginning of a
script file.
-Duncan
A regrettable precedent, perhaps? Although it's an OS feature that is well documented and used on multiple platforms. In any case, I think the "correct" response to this problem is...
From http://www.lua.org/manual/5.1/manual.html#pdf-load
>
> load(func [, chunkname])
> Loads a chunk using function func to get its pieces.
function utf8_dofile(filename)
 return assert(load(
 function()
 return string.gsub(
 assert(io.open(filename)):read('*a'),
 '^239円187円191円', '')
 end,
 filename
 ))()
end
Or something like that.
--
- tom
telliamed@whoopdedo.org

AltStyle によって変換されたページ (->オリジナル) /