ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Problem processing a non-UTF8 Lua script
@ 2010-10-21  8:00 Procházka Lukáš
  2010-10-21 15:49 ` Vedran Miletić
  0 siblings, 1 reply; 7+ messages in thread
From: Procházka Lukáš @ 2010-10-21  8:00 UTC (permalink / raw)
  To: ConTeXt

[-- Attachment #1: Type: text/plain, Size: 5957 bytes --]

Hello,

I have a problem with processing a Lua file similar to that with \typefile described several days (weeks?) ago.

Let's have the following files:

- Ctx:

---
\mainlanguage[cz]
\enableregime[cp1250]

\starttext
   AAA

   \startluacode
     local t = dofile("t.lua")

     context(t)
   \stopluacode
\stoptext
---

- And the t.lua:

---
-- return "111" -- This worked OK
return "žšč" -- This is problem for Ctx
---

When I try the t.lua from Win console by "Lua -e dofile('t.lua')", there is no problem.

When I run the Ctx file, it has problem processing characters with diacritics (like "čřž..."); the t.lua is not encoded in UTF-8 (which seems to be supposed by Ctx-Lua), but I'm using the cp1250 code page + each character = 1 B.

The error message is:

---
MTXrun | run 1: luatex --fmt="c:/ConTeXt/tex/texmf-cache/luatex-cache/context/f53042fa2e1c106bc7e3383ec8c3a00c/formats/cont-en" --lua="c:/ConTeXt/tex/texmf-cache/luatex-cache/context/f53042fa2e1c106bc7e3383ec8c3a00c/formats/cont-en.lui" --backend=pdf "D:/L
ukas/ConTeXt/Samples/U8/t-U8.mkiv"This is LuaTeX, Version beta-0.63.0-2010090921 (rev 3873)
  \write18 enabled.
(D:/Lukas/ConTeXt/Samples/U8/t-U8.mkiv
jobcontrol      > resuming randomizer with 0.50767540513321

ConTeXt  ver: 2010.10.20 21:33 MKIV  fmt: 2010.10.21  int: english/english

system          : cont-new loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-new.tex
systems         : beware: some patches loaded from cont-new.tex
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-new.mkiv))
system          : cont-fil.mkiv loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-fil.mkiv
loading         : ConTeXt File Synonyms
)
system          : cont-sys.rme loaded
(c:/ConTeXt/tex/texmf-context/tex/context/user/cont-sys.rme (c:/ConTeXt/tex/texmf-context/tex/context/base/type-def.mkiv) (c:/ConTeXt/tex/texmf-context/tex/context/base/type-lua.mkiv) (c:/ConTeXt/tex/texmf-context/tex/context/base/type-siz.mkiv) (c:/ConTeX
t/tex/texmf-context/tex/context/base/type-otf.mkiv))
system          : cont-err loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-err.tex
systems         : no file 'cont-sys.tex', using 'cont-sys.rme' instead
)
system          : t-U8.top loaded
(t-U8.top
)
fonts           : preloading latin modern fonts
{c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-math.map}{c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-rm.map}{c:/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map}
bodyfont        : 12pt rm is loaded
language        : language en is active
publications    : loading formatting style from bxml-apa
(c:/ConTeXt/tex/texmf-context/tex/context/base/bxml-apa.mkiv)
systems         : begin file D:/Lukas/ConTeXt/Samples/U8/t-U8.mkiv at line 4
! String contains an invalid utf-8 sequence.

system          > error on line 1 in file D:/Lukas/ConTeXt/Samples/U8/t-U8.mkiv: String contains an invalid utf-8 sequence ...

  1 >>  \mainlanguage[cz]
  2     \enableregime[cp1250]
  3
  4     \starttext
  5       AAA
  6
  7       \startluacode
  8         local t = dofile("t.lua")
  9
10         context(t)
11       \stopluacode

l.1
     ×ÜŔ
   } context(t)> ...le("t.lua")

\dodostartluacode ...d \directlua \zerocount {#1}}

l.11   \stopluacode

backends        > using xmp file 'c:/ConTeXt/tex/texmf-context/tex/context/base/lpdf-pdx.xml'
pages           > flushing realpage 1, userpage 1, subpage 1
systems         : end file D:/Lukas/ConTeXt/Samples/U8/t-U8.mkiv at line 12
  )<c:/ConTeXt/tex/texmf/fonts/opentype/public/lm/lmroman12-regular.otf>
mkiv lua stats : used config file          - c:/ConTeXt/tex/texmf/web2c/texmfcnf.lua
mkiv lua stats : used cache path           - c:/ConTeXt/tex/texmf-cache/luatex-cache/context/f53042fa2e1c106bc7e3383ec8c3a00c
mkiv lua stats : input load time           - 0.094 seconds
mkiv lua stats : stored bytecode data      - 241 modules, 56 tables, 297 chunks
mkiv lua stats : cleaned up reserved nodes - 33 nodes, 9 lists of 411
mkiv lua stats : node memory usage         - 19 glue_spec
mkiv lua stats : node list callback tasks  - 6 unique task lists, 5 instances (re)created, 328 calls
mkiv lua stats : used backend              - pdf (backend for directly generating pdf output)
mkiv lua stats : loaded patterns           - cs::23 en::2
mkiv lua stats : language load time        - 0.156 seconds , nofpatterns: 2
mkiv lua stats : callbacks                 - direct: 480, indirect: 4507, total: 4987
mkiv lua stats : lxml preparation time     - 0.000 seconds, 0 nodes, 15 lpath calls, 0 cached calls
mkiv lua stats : result saved in file      - t-U8.pdf
mkiv lua stats : loaded fonts              - 33 files: stmary10.afm lmmono12-regular.otf lmmono8-regular.otf lmmono9-regular.otf lmroman12-bold.otf lmroman12-regular.otf lmroman7-bold.otf lmroman7-regular.otf lmroman9-bold.otf lmroman9-regular.otf lmsans12
-regular.otf lmsans8-regular.otf lmsans9-regular.otf eufb10.tfm eufb7.tfm eufm10.tfm eufm7.tfm msam10.tfm msam7.tfm msbm10.tfm msbm7.tfm lmex10.tfm lmmi12.tfm lmmi7.tfm lmmi9.tfm lmmib10.tfm lmmib7.tfm lmsy10.tfm lmsy7.tfm lmsy9.tfm rm-lmr12.tfm rm-lmr7.tf
m rm-lmr9.tfm
mkiv lua stats : fonts load time           - 1.141 seconds
mkiv lua stats : luatex banner             - this is luatex, version beta-0.63.0-2010090921 (web2c 2010) (rev 3873)
mkiv lua stats : control sequences         - 30353 of 165536
mkiv lua stats : current memory usage      - 33 MB (ctx: 33 MB)
mkiv lua stats : runtime                   - 3.531 seconds, 1 processed pages, 1 shipped pages, 0.283 pages/second
---

So would it be possible to specify for Ctx which coding to use when using a Lua file by 'require' or 'dofile'?

- Or could this be depending on \enableregime specified in Ctx source file before \startluacode?

Or how to make Ctx work with non-UTF8 Lua files?

Lukas


NB: Latest minimals, WinXP.

[-- Attachment #2: t.lua --]
[-- Type: application/octet-stream, Size: 22 bytes --]

[-- Attachment #3: t-U8.mkiv --]
[-- Type: application/octet-stream, Size: 146 bytes --]

\mainlanguage[cz]
\enableregime[cp1250]

\starttext
  AAA

  \startluacode
    local t = dofile("t.lua")

    context(t)
  \stopluacode
\stoptext

[-- Attachment #4: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem processing a non-UTF8 Lua script
  2010-10-21  8:00 Problem processing a non-UTF8 Lua script Procházka Lukáš
@ 2010-10-21 15:49 ` Vedran Miletić
  2010-10-21 16:55   ` Mojca Miklavec
  2010-10-21 17:47   ` Procházka Lukáš
  0 siblings, 2 replies; 7+ messages in thread
From: Vedran Miletić @ 2010-10-21 15:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2010/10/21 Procházka Lukáš <lpr@pontex.cz>:
> Or how to make Ctx work with non-UTF8 Lua files?
>
> Lukas
>
>
> NB: Latest minimals, WinXP.

Notepad supports saving to UTF-8. Can't you rather convert your files to it?

-- 
Vedran Miletić
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem processing a non-UTF8 Lua script
  2010-10-21 15:49 ` Vedran Miletić
@ 2010-10-21 16:55   ` Mojca Miklavec
  2010-10-21 17:04     ` Mojca Miklavec
                       ` (2 more replies)
  2010-10-21 17:47   ` Procházka Lukáš
  1 sibling, 3 replies; 7+ messages in thread
From: Mojca Miklavec @ 2010-10-21 16:55 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2010/10/21 Vedran Miletić <rivanvx@gmail.com>:
> 2010/10/21 Procházka Lukáš <lpr@pontex.cz>:
>> Or how to make Ctx work with non-UTF8 Lua files?
>
> Notepad supports saving to UTF-8. Can't you rather convert your files to it?

Come on ... Lukáš is merely trying to remove all the codepage-related
problems in MKIV :) :) :)

(Hans will hate me for having suggested to support
\enableregime[cp1250] in MKIV in the first place, else there would at
least be an excuse such as "sorry, but luatex doesn't support anything
but utf-8" :)

Mojca

PS: even vim uses cp1250 on windows 7 by default
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem processing a non-UTF8 Lua script
  2010-10-21 16:55   ` Mojca Miklavec
@ 2010-10-21 17:04     ` Mojca Miklavec
  2010-10-21 17:13     ` Hans Hagen
  2010-10-21 18:32     ` Arthur Reutenauer
  2 siblings, 0 replies; 7+ messages in thread
From: Mojca Miklavec @ 2010-10-21 17:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, Oct 21, 2010 at 18:55, Mojca Miklavec wrote:
>
> Come on ... Lukáš is merely trying to remove all the codepage-related
> problems in MKIV :) :) :)

But then ... I admit that this case is so ugly that even I'm not sure
if I would want to fix it and support it.

I can imagine arbitrary complex mixtures of tex/lua/metapost/index
sorting routine calling each other recursively ... and sooner or later
this would probably break in one way or another even if some
particular case gets fixed.

Mojca
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem processing a non-UTF8 Lua script
  2010-10-21 16:55   ` Mojca Miklavec
  2010-10-21 17:04     ` Mojca Miklavec
@ 2010-10-21 17:13     ` Hans Hagen
  2010-10-21 18:32     ` Arthur Reutenauer
  2 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2010-10-21 17:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Mojca Miklavec

On 21-10-2010 6:55, Mojca Miklavec wrote:
> 2010/10/21 Vedran Miletić<rivanvx@gmail.com>:
>> 2010/10/21 Procházka Lukáš<lpr@pontex.cz>:
>>> Or how to make Ctx work with non-UTF8 Lua files?
>>
>> Notepad supports saving to UTF-8. Can't you rather convert your files to it?
>
> Come on ... Lukáš is merely trying to remove all the codepage-related
> problems in MKIV :) :) :)
>
> (Hans will hate me for having suggested to support
> \enableregime[cp1250] in MKIV in the first place, else there would at
> least be an excuse such as "sorry, but luatex doesn't support anything
> but utf-8" :)

Don't worry, I have no problem with enableregime, but messing around 
with lua scripts and locales and codepages is asking for troubles and 
I'm not going to waste time on that.

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem processing a non-UTF8 Lua script
  2010-10-21 15:49 ` Vedran Miletić
  2010-10-21 16:55   ` Mojca Miklavec
@ 2010-10-21 17:47   ` Procházka Lukáš
  1 sibling, 0 replies; 7+ messages in thread
From: Procházka Lukáš @ 2010-10-21 17:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Well, I've done it by the proposed way in this particular case.

(I.e. I have the only one UTF-8 coded file - and this is the only one text file in general - for this one case.

TextPad supports various codings as well.

I was not sure whether the text editor will be able to determine coding used, so I worried about having to select encoding every time I'd like to edit this Lua file.

But, fortunately, the editor is able to determine the UTF-8 coding; and the CP1250 as well.

So once I saved this Lua file with UTF-8 encoding, I don't have to reselect it.)

Lukas


On Thu, 21 Oct 2010 17:49:43 +0200, Vedran Miletić <rivanvx@gmail.com> wrote:

> 2010/10/21 Procházka Lukáš <lpr@pontex.cz>:
>> Or how to make Ctx work with non-UTF8 Lua files?

>
> Notepad supports saving to UTF-8. Can't you rather convert your files to it?
>



___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem processing a non-UTF8 Lua script
  2010-10-21 16:55   ` Mojca Miklavec
  2010-10-21 17:04     ` Mojca Miklavec
  2010-10-21 17:13     ` Hans Hagen
@ 2010-10-21 18:32     ` Arthur Reutenauer
  2 siblings, 0 replies; 7+ messages in thread
From: Arthur Reutenauer @ 2010-10-21 18:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Oct 21, 2010, at 18:55, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote:
> PS: even vim uses cp1250 on windows 7 by default

  I think that's highly configurable.  But it's true that configuration defaults have an important role, too.

    Arthur
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-10-21 18:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-21  8:00 Problem processing a non-UTF8 Lua script Procházka Lukáš
2010-10-21 15:49 ` Vedran Miletić
2010-10-21 16:55   ` Mojca Miklavec
2010-10-21 17:04     ` Mojca Miklavec
2010-10-21 17:13     ` Hans Hagen
2010-10-21 18:32     ` Arthur Reutenauer
2010-10-21 17:47   ` Procházka Lukáš

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).