| 1 |
libtextwrap - Text-Wrapping Library with I18N |
| 2 |
|
| 3 |
|
| 4 |
Introduction |
| 5 |
------------ |
| 6 |
|
| 7 |
Word-wrapping (or line-folding) is one of frequently used text-processing. |
| 8 |
It is implemented very easily only when it is based on several assumptions |
| 9 |
such as: |
| 10 |
|
| 11 |
- One character consists from one byte. |
| 12 |
- One character occupies one column on the terminal. |
| 13 |
- A line can be folded between words which are separated by whitespaces. |
| 14 |
|
| 15 |
All of these assumptions are *local* and valid only for some |
| 16 |
part of languages in the world. There are languages which don't meet |
| 17 |
the assumptions and speakers of such languages cannot use softwares |
| 18 |
which depend on these assumptions. |
| 19 |
|
| 20 |
Since it is usually difficult to require developers to know various |
| 21 |
languages in the world and their properties, text-processing |
| 22 |
algorithms should be supplied as libraries. Otherwise, their softwares |
| 23 |
cannot support various languages in the world and people in the world |
| 24 |
suffer from a problem that many softwares are useless for them. |
| 25 |
|
| 26 |
|
| 27 |
Feature |
| 28 |
------- |
| 29 |
|
| 30 |
On calling a function with parameters of text and maximum columns, |
| 31 |
one can get line-folded text. The text is encoded in current LC_CTYPE |
| 32 |
locale. This means that libtextwrap uses UTF-8 for I/O in UTF-8 locales, |
| 33 |
ISO-8859-1 in ISO-8859-1 locales, EUC-JP in EUC-JP locales, KOI8-R in |
| 34 |
KOI8-R locales, and so on. |
| 35 |
|
| 36 |
|
| 37 |
Download |
| 38 |
-------- |
| 39 |
|
| 40 |
Please visit http://libtextwrap.sourceforge.net/ . |
| 41 |
|
| 42 |
|
| 43 |
Compilation |
| 44 |
----------- |
| 45 |
|
| 46 |
When you are using released version, do like following: |
| 47 |
|
| 48 |
$ ./configure |
| 49 |
$ make |
| 50 |
$ make install |
| 51 |
|
| 52 |
When you are using CVS version, you will have to run |
| 53 |
|
| 54 |
$ ./bootstrap |
| 55 |
|
| 56 |
before invoking ./configure script. You will need autoconf, |
| 57 |
automake, and libtool in this case. |
| 58 |
|
| 59 |
|
| 60 |
Usage |
| 61 |
----- |
| 62 |
|
| 63 |
See the manpage of textwrap(3). Like following: |
| 64 |
|
| 65 |
#include <stdio.h> |
| 66 |
#include <locale.h> |
| 67 |
#include <textwrap.h> |
| 68 |
int main(int argc, char **argv) |
| 69 |
{ |
| 70 |
textwrap_t property; |
| 71 |
|
| 72 |
setlocale(LC_ALL, ""); |
| 73 |
textwrap_init(&property); |
| 74 |
textwrap_columns(&property, 40); |
| 75 |
|
| 76 |
printf("Input string:\n%s\n", argv[1]); |
| 77 |
printf("Formatted string:\n%s\n", |
| 78 |
textwrap(&property, argv[1])); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
Sample Program |
| 83 |
-------------- |
| 84 |
|
| 85 |
dotextwrap.c is a test program to invoke libtextwrap. |
| 86 |
It is compiled and installed at the same time as libtextwrap. |
| 87 |
Read dotextwrap(1) for detail. |
| 88 |
|
| 89 |
sample/testprog.pl is a test program for libtextwrap with |
| 90 |
multilingual text. Just invoke it. |
| 91 |
|
| 92 |
|
| 93 |
License |
| 94 |
------- |
| 95 |
|
| 96 |
Copyright (c) 2003 by Tomohiro KUBOTA <[email protected]> |
| 97 |
|
| 98 |
Redistribution and use in source and binary forms, with or without |
| 99 |
modification, are permitted provided that the following conditions |
| 100 |
are met: |
| 101 |
1. Redistributions of source code must retain the above copyright |
| 102 |
notice, this list of conditions and the following disclaimer. |
| 103 |
2. Redistributions in binary form must reproduce the above copyright |
| 104 |
notice, this list of conditions and the following disclaimer in the |
| 105 |
documentation and/or other materials provided with the distribution. |
| 106 |
3. The name of any author may not be used to endorse or promote |
| 107 |
products derived from this software without their specific prior |
| 108 |
written permission. |
| 109 |
|
| 110 |
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 111 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 112 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 113 |
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 114 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 115 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 116 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 117 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 118 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 119 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 120 |
SUCH DAMAGE. |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
The sample texts in sample/testprog.pl are citations from Debian website |
| 125 |
(http://www.debian.org/). |
| 126 |
|
| 127 |
Copyright (c) 1997-2003 Software in the Public Interest, Inc. |
| 128 |
P.O. Box 502761 |
| 129 |
Indianapolis, IN 46250-2761 |
| 130 |
United States |
| 131 |
|
| 132 |
This material may be distributed only subject to the terms and conditions |
| 133 |
set forth in the Open Publication License, Draft v1.0 or later (the latest |
| 134 |
version is presently available at http://www.opencontent.org/openpub/). |
| 135 |
|
| 136 |
"Debian" and the Debian Logo are trademarks of Software in the Public |
| 137 |
Interest, Inc. |