$Id: README,v 1.2 2001/05/04 11:04:18 malekith Exp $

------------> QApprox.hs, qapprox2table.pl

QApprox.hs file comes from QForeign project by Marcin 'Qrczak' Kowalczyk.
QForeign's home is at <http://www.sourceforge.net/projects/qforeign/>.
It's left untouched, so newer version hopefully may be placed here w/o
any modifcations (this comes from qforeign-0.65.tar.gz).

qapprox2table.pl Perl script translates QApprox Haskell source into hashed
table suitable for use in C.

Format:

> To: y-window@pld.org.pl
> Subject: Re: Unicode fallback table
> From: Marcin 'Qrczak' Kowalczyk <qrczak@knm.org.pl>
> 
> [snip]
> 
> 1. http://prdownloads.sourceforge.net/qforeign/qforeign-0.65.tar.gz
>     file qforeign/lib/QApprox.hs
> 
> [snip]
> 
> 1. is encoded using Haskell's lexical rules and hex escapes. The sequence
> \& means an empty string and is used to separate a hex number from the
> next character. A character \0 inside a target sequence means that the
> sequence ends before \0 but it should be used only if characters after \0
> are available as well. Language-dependent additions are in separate
> tables.
> 
> [snip]

And word from me about generated table:

one symbol is exported, it's name should be passed as first argument to
qapprox2table.pl, like this:

./qapprox2table.pl yw_fallback_table < QApprox.hs > table.inc

File table.inc will contain C source, with one exported symbol:

uint16_t *yw_fallback_table[].

(uint16_t should be defined before including table.inc).

p = yw_fallback_table[n] contains pointer to approximations of all characters
of code u, for which ((u & 0xff) ^ ((u >> 8) & 0xff)) == n.

p[0] is number such characters * 2.
p[1 + k * 2] is one such character code (where k < p[0]/2).
p[1 + k * 2 + 1] is offset of approximations.

offset is counted from p[p[0]].

Approximations comes in following format:
(length_of_string, string_char{length_of_string})*
last approximation has length == 0.

Languge dependent fallbacks are *not* included.


