|
Packit |
57a33d |
# Developing programs utilizing libenca
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
* Look at libenca API documentation in devel-docs/html.
|
|
Packit |
57a33d |
* Look into enca source how it uses libenca. Note enca is quite a simple
|
|
Packit |
57a33d |
application (practically all libenca interaction is in `src/enca.c`). It's
|
|
Packit |
57a33d |
single-threaded and uses one language and one analyser all the time.
|
|
Packit |
57a33d |
Provided each thread has its own analyser, libenca should be thread-safe
|
|
Packit |
57a33d |
(untested).
|
|
Packit |
57a33d |
* Take names starting with `ENCA`, `Enca`, `enca`, `_ENCA`, `_Enca`, and
|
|
Packit |
57a33d |
`_enca` as reserved.
|
|
Packit |
57a33d |
* pkgconfig is supported, you can use `PKG_CHECK_MODULES` to check for libenca
|
|
Packit |
57a33d |
in your configure scripts
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
# How to add a new charset/encoding
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
(optional steps are marked _[optional]_):
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
* `iconvcap.c`:
|
|
Packit |
57a33d |
* Add a new test (even if you are 100% sure iconv will never support it),
|
|
Packit |
57a33d |
please see top of `iconvcap.c` for some documentation how it works.
|
|
Packit |
57a33d |
* `tools/encodings.dat`:
|
|
Packit |
57a33d |
* Add a new entry.
|
|
Packit |
57a33d |
* Use `@ICONV_NAME_<name>@` (as it will appear in iconvcap output) for
|
|
Packit |
57a33d |
iconv names.
|
|
Packit |
57a33d |
* `tools/iconvenc.null`:
|
|
Packit |
57a33d |
* Add it (with NULL)
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
Specifically, for regular 8bit (language dependent) charsets:
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
* `lib/unicodemap.c`:
|
|
Packit |
57a33d |
* Add a new map to Unicode (UCS-2) `unicode_map_...[]`.
|
|
Packit |
57a33d |
* Add a new `UNICODE_MAP[]` entry.
|
|
Packit |
57a33d |
* `lib/filters.c`: _[optional]_
|
|
Packit |
57a33d |
* Create a new filter or make an alias of an existing filter.
|
|
Packit |
57a33d |
* `lib/lang_??.c`:
|
|
Packit |
57a33d |
* Add the new encoding to some existing language(s).
|
|
Packit |
57a33d |
* Add appropriate filters or hooks _[optional]_.
|
|
Packit |
57a33d |
* `data/maps/??.map`:
|
|
Packit |
57a33d |
* Add a new map to Unicode (UCS-2)
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
Specifically, for multibyte encodings:
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
* `lib/multibyte.c`:
|
|
Packit |
57a33d |
* Create a new check function.
|
|
Packit |
57a33d |
* Put it into appropriate ascii/8bit/binary test group
|
|
Packit |
57a33d |
`ENCA_MULTIBYTE_TESTS_ASCII[]`, `ENCA_MULTIBYTE_TESTS_8BIT[]`,
|
|
Packit |
57a33d |
`ENCA_MULTIBYTE_TESTS_BINARY[]`.
|
|
Packit |
57a33d |
* Put strict tests (i.e. test which may fail) first, looks-like tests
|
|
Packit |
57a33d |
last.
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
# How to add a new surface
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
* Try to ask the author what to do, since this may be complicated, or
|
|
Packit |
57a33d |
* Hack, basically it must be added to `lib/enca.h` `EncaSurface enum`, to
|
|
Packit |
57a33d |
`lib/encnames.c` `SURFACE_INFO[]` a detection method must be added to
|
|
Packit |
57a33d |
`lib/guess.c` and now the most complicated part: this new method must be used
|
|
Packit |
57a33d |
in the right places in `lib/guess.c` `make_guess()`.
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
# How to add a new language
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
* Create a new language file:
|
|
Packit |
57a33d |
* Create new `lib/lang_....c` files by copying some existing (use locale
|
|
Packit |
57a33d |
code for names)
|
|
Packit |
57a33d |
* Fill all encoding and occurence data, create filters and hooks (see
|
|
Packit |
57a33d |
`filters.c` too). You can do it manually, but look how it's done for
|
|
Packit |
57a33d |
existing languages in `data/*` and read `data/README`.
|
|
Packit |
57a33d |
* `lib/internal.h`:
|
|
Packit |
57a33d |
* Add new `ENCA_LANGUAGE_....`
|
|
Packit |
57a33d |
* `src/lang.c`:
|
|
Packit |
57a33d |
* Add a new `LANGUAGE_LIST[]` entry pointing to the `ENCA_LANGUAGE_....`
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
# Automake, autoconf, libtool, ... note
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
If you run `./autogen.sh` and it finishes OK, you are lucky and can expect
|
|
Packit |
57a33d |
things to work.
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
You have to give `--enable-maintainer-mode` to `./configure` (or `./autogen`)
|
|
Packit |
57a33d |
to build dists and/or the strange stuff in `tools/`, `data/`, `tests/`, and
|
|
Packit |
57a33d |
`devel-docs/`.
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
# Repository and continuous integration
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
The git repository is located at GitHub:
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
http://github.com/nijel/enca
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
There is also continuous integration on Travis:
|
|
Packit |
57a33d |
|
|
Packit |
57a33d |
https://travis-ci.org/nijel/enca
|