On 10-2-2012 14:15, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
Dunno but it works when you use “regimes.translate” in your code but it’s better to ask Hans for a function in the commands namespace which you can use.
\starttext
\startluacode
function loadFile(fn) local fh = assert(io.open(fn, "r")) local str = fh:read("*all") fh:close() str = regimes.translate(str,"cp1250") context(str) end
loadFile("a.txt")
\stopluacode
\stoptext
Wolfgang
Thank you, Wolfgang.
Your code works perfectly and does exactly what I need.
As oneliner ... function document.MyLoadFile(name) context(regimes.translate(io.loaddata(resolvers.findfile(name)),"cp1250")) end (resolvers will look up in the tree if needed) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------