[luatex] lua-inputenc

Ulrike Fischer news2 at nililand.de
Wed Feb 18 12:36:49 CET 2009


Am Wed, 18 Feb 2009 11:53:21 +0100 schrieb Javier Múgica:

> I didn't conect to the internet in the past days and haven't red the
> whole discussion, so may be this was already pointed:
> 
> In order to run my old LaTeX documents with luatex I also thought
> about the writing an inputenc, registering differnt callbacks for
> process_input_buffer according to the encoding, but then I realized
> that it was much easier to simply register a function for
> process_input_buffer in such a way as to change from byte to utf-8,
> and then just let LateX inputenc (or whatever code) to handle the
> input encoding.
> 
> Now I don't have the code with me, but Is was fairly simple and I
> think I can write it now:
> 
> \directlua0{
> function byte-to-utf8(string c)
>   local b=string.byte(c)
>   if b<128 then
>      return c
>   end
>   if b<192 then
>     return string.char(194, b)
>   else
>     return string.char(194,b-64)
>   end
> end
> 
> callback.register(
> function process_input_buffer(buffer)
>   return string.gsub(buffer,"(.)",byte-to-utf8)
> end
> )
> }

I'm not very good at lua but I do have some doubt that chars which
use 3 octets for coding will come out correctly. E.g. the euro-sign
has in ansinew the position 128, so if I understand your code
correctly it will be mapped to 

0xC2 0x80, but its utf8 code is 0xE2 0x82 0xAC


-- 
Ulrike Fischer 



More information about the luatex mailing list