| 1 |
libguess - a high-speed character set detection library |
| 2 |
------------------------------------------------------- |
| 3 |
|
| 4 |
libguess is free, but copyrighted software. See COPYING for details. |
| 5 |
|
| 6 |
Using libguess in your programs: |
| 7 |
-------------------------------- |
| 8 |
|
| 9 |
libguess has two functions: |
| 10 |
|
| 11 |
- libguess_determine_encoding(const char *inbuf, int length, const char *region); |
| 12 |
|
| 13 |
This detects a character set. Returns an appropriate charset name |
| 14 |
that can be passed to iconv_open(). Region is the name of the language |
| 15 |
or region that the data is related to, e.g. 'Baltic' for the Baltic states, |
| 16 |
or 'Japanese' for Japan. |
| 17 |
|
| 18 |
- libguess_validate_utf8(const char *inbuf, int length); |
| 19 |
|
| 20 |
This employs libguess's DFA-based character set validation rules to ensure |
| 21 |
that a string is pure UTF-8. GLib's UTF-8 validation functions are broken, |
| 22 |
for example. |
| 23 |
|
| 24 |
Just include libguess.h and link to libguess to get these functions in your |
| 25 |
program. For your convenience, a pkg-config file is also supplied. |
| 26 |
|
| 27 |
How does libguess work: |
| 28 |
----------------------- |
| 29 |
|
| 30 |
libguess employs discrete-finite automata to deduce the character set of the |
| 31 |
input buffer. The advantage of this is that all character sets can be checked |
| 32 |
in parallel, and quickly. Right now, libguess passes a byte to each DFA on the |
| 33 |
same pass, meaning that the winning character set can be deduced as efficiently |
| 34 |
as possible. |
| 35 |
|
| 36 |
libguess is fully reentrant, using only local stack memory for DFA operations. |
| 37 |
|
| 38 |
I found a bug: |
| 39 |
-------------- |
| 40 |
|
| 41 |
Please report your bug using GitHub issues. |