[NTG-context] Chinese in ConTeXt

Hans Hagen pragma at wxs.nl
Tue May 31 09:33:55 CEST 2005


Lutz Haseloff wrote:

> b.t.w. I think, \dohandleunicodeflowglyph doesn't handle
> some glyphs right. Particularly the glyphs with parenthesis
> {} and Backslash.
> 
> ConTeXt complains about my qianziwen-Big5.tex:
> 
> 
> -------------------------------------------
> ! Use of \dohandleunicodeflowglyph doesn't match its definition.
> <recently read> ¦
> 
> \handleunicodeflowglyph ...ttoken \@EA `\string #2
>                                                   \relax
> l.18 »\¦
>         ¹¨­µo¡A¥|¤j¤­±`¡C®¥±©Áù¾i¡A°Z´±·´¶Ë¡C
> ?
> -------------------------------------------
> 
> 
> Attached GBK-file works fine.
> 
> Is it possible to make \dohandleunicodeflowglyph more robust
> to handle those big5 glyphs right?
> Or is it my mistake again?

i may be wrong (long ago that i made that-) but those file needs some treatment 
(esp when one uses arguments)

tex2uc yourfile
texexec yourfile
uc2tex yourfile

actually, since i have a indirect option in texexec (for xml) i can make this 
automatic, e.g. when the first line has something

% preprocess=tex2uc

I must think of it; remind me

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
-------------- next part --------------
# ConTeXt uc converter / beta version / 2-12-1999 / don't redistribute 

$filename = $ARGV[0] ; 
$recoded  = 0 ; 

sub unirecoded
  { print chr($_[1]) ; ++$recoded ; return chr($_[0]).chr($_[1]) } 

if ((open(INP,"$filename.tex"))&&(open(OUT,">$filename.tmp")))
  { print "processing file $filename.tex " ;
    while (<INP>) 
      { s/\\uc\{(\d*)\}\{(\d*)\}/unirecoded($1,$2)/goe ; print OUT $_ } 
    close(INP) ; 
    close(OUT) ; 
    unlink "$filename.tec" ; 
    rename "$filename.tex", "$filename.tec" ;
    rename "$filename.tmp", "$filename.tex" ; 
    if ($recoded) 
      { print " - $recoded glyphs recoded - original saved as $filename.tec\n" } 
    else
      { print "- no glyphs recoded\n" } }
else 
  { print "invalid filename\n" } 
-------------- next part --------------
# ConTeXt uc converter / beta version / 2-12-1999 / don't redistribute 

if ($ARGV[0] ne '') 
  { @filenames = @ARGV } 
else
  { @filenames = glob "*.tex" }

foreach (@filenames) { s/\.tex$//io }  

sub unirecode
  { my ($a,$b) = @_ ;
    if ((ord($b)<0x80)&&($b !~ /[a-zA-Z0-9]/))
      { print "$b" ; ++$recoded ;  
        return "\\uc\{" . ord($a) . "\}\{". ord($b) . "\}" }  
    else
      { return "$a$b" } } 

foreach $filename (@filenames) 
 { if (open(INP,"$filename.tex"))
     { $recoded  = 0 ; 
       print "processing file $filename.tex " ;
       $/ = "\0777" ; 
       $_ = <INP> ;
       close(INP) ; 
       s/([\x80-\xFF])(.)/unirecode($1,$2)/mgoe ; 
       if (($recoded)&&(open(OUT,">$filename.tmp")))
         { print OUT $_ ;
           close(OUT) ; 
           unlink "$filename.tec" ; 
           rename "$filename.tex", "$filename.tec" ;
           rename "$filename.tmp", "$filename.tex" } 
       if ($recoded) 
         { print " - $recoded glyphs recoded - original saved as $filename.tec\n" } 
       else
         { print "- no glyphs recoded\n" } }
   else      
     { print "invalid filename\n" } }



More information about the ntg-context mailing list