1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename libunistring.info
4 @documentencoding UTF-8
5 @settitle GNU libunistring
8 @c am = autoconf macro @amindex
9 @c cp = concept @cindex
10 @c fn = function @findex
12 @c Unused predefined indices:
13 @c ky = keystroke @kindex
14 @c pg = program @pindex
15 @c vr = variable @vindex
21 @firstparagraphindent insert
23 @c texi2html-1.76 does not support @arrow{}.
29 @comment %**end of header
33 @c Location of the POSIX specification on the web.
34 @set POSIXURL http://www.opengroup.org/onlinepubs/9699919799
36 @c Macro for referencing a POSIX function.
37 @c We don't write it as func(), see section "GNU Manuals" of the
38 @c GNU coding standards.
40 @macro posixfunc{func}
45 @macro posixfunc{func}
46 @uref{@value{POSIXURL}/functions/\func\.html,,@code{\func\}}
50 @c Macro for referencing a normal function.
51 @c We don't write it as func(), see section "GNU Manuals" of the
52 @c GNU coding standards.
57 @c Macro for an advisory ragged line break in TeX mode.
58 @c Needed because there are long unbreakable pieces of text (such as URLs or
59 @c formulas), TeX is too shy to move them to a new line. TeX considers only
60 @c two choices: a line break in aligned mode (which it rejects due to aesthetic
61 @c reasons) and writing into the margin. What we want in many cases is a line
62 @c break without filling the first line. Like what @* delivers. But we want it
63 @c only when needed, so that it disappears when unrelated changes in the same
64 @c paragraph cause a line break in a nearby position. And we need it only in
65 @c TeX mode. info and HTML modes are fine.
66 @c This trick is from Karl Berry.
69 @hfil@penalty9000@hfilneg
78 @dircategory Software development
80 * GNU libunistring: (libunistring). Unicode string library.
85 This manual is for GNU libunistring.
88 @c This was: @copying but it triggers a makeinfo 4.13 bug
89 Copyright (C) 2001-2010 Free Software Foundation, Inc.
91 This manual is free documentation. It is dually licensed under the
92 GNU FDL and the GNU GPL. This means that you can redistribute this
93 manual under either of these two licenses, at your choice.
95 This manual is covered by the GNU FDL. Permission is granted to copy,
96 distribute and/or modify this document under the terms of the
97 GNU Free Documentation License (FDL), either version 1.2 of the
98 License, or (at your option) any later version published by the
99 Free Software Foundation (FSF); with no Invariant Sections, with no
100 Front-Cover Text, and with no Back-Cover Texts.
101 A copy of the license is included in @ref{GNU FDL}.
103 This manual is covered by the GNU GPL. You can redistribute it and/or
104 modify it under the terms of the GNU General Public License (GPL), either
105 version 3 of the License, or (at your option) any later version published
106 by the Free Software Foundation (FSF).
107 A copy of the license is included in @ref{GNU GPL}.
112 @title GNU libunistring, version @value{VERSION}
113 @subtitle updated @value{UPDATED}
114 @subtitle Edition @value{EDITION}, @value{UPDATED}
119 @vskip 0pt plus 1filll
121 Copyright (C) 2001-2010 Free Software Foundation, Inc.
123 This manual is free documentation. It is dually licensed under the
124 GNU FDL and the GNU GPL. This means that you can redistribute this
125 manual under either of these two licenses, at your choice.
127 This manual is covered by the GNU FDL. Permission is granted to copy,
128 distribute and/or modify this document under the terms of the
129 GNU Free Documentation License (FDL), either version 1.2 of the
130 License, or (at your option) any later version published by the
131 Free Software Foundation (FSF); with no Invariant Sections, with no
132 Front-Cover Text, and with no Back-Cover Texts.
133 A copy of the license is included in @ref{GNU FDL}.
135 This manual is covered by the GNU GPL. You can redistribute it and/or
136 modify it under the terms of the GNU General Public License (GPL), either
137 version 3 of the License, or (at your option) any later version published
138 by the Free Software Foundation (FSF).
139 A copy of the license is included in @ref{GNU GPL}.
148 @top GNU libunistring
152 * Introduction:: Who may need Unicode strings?
153 * Conventions:: Conventions used in this manual
154 * unitypes.h:: Elementary types
155 * unistr.h:: Elementary Unicode string functions
156 * uniconv.h:: Conversions between Unicode and encodings
157 * unistdio.h:: Output with Unicode strings
158 * uniname.h:: Names of Unicode characters
159 * unictype.h:: Unicode character classification and properties
160 * uniwidth.h:: Display width
161 * unigbrk.h:: Grapheme cluster breaking
162 * uniwbrk.h:: Word breaks in strings
163 * unilbrk.h:: Line breaking
164 * uninorm.h:: Normalization forms
165 * unicase.h:: Case mappings
166 * uniregex.h:: Regular expressions
167 * Using the library:: How to link with the library and use it?
168 * More functionality:: More advanced functionality
169 * Licenses:: Licenses
171 * Index:: General Index
174 --- The Detailed Node Listing ---
178 * Unicode:: What is Unicode?
179 * Unicode and i18n:: Unicode and internationalization
180 * Locale encodings:: What is a locale encoding?
181 * In-memory representation:: How to represent strings in memory?
182 * char * strings:: What to keep in mind with @code{char *} strings
183 * The wchar_t mess:: Why @code{wchar_t *} strings are useless
184 * Unicode strings:: How are Unicode strings represented?
188 * Elementary string checks::
189 * Elementary string conversions::
190 * Elementary string functions::
191 * Elementary string functions with memory allocation::
192 * Elementary string functions on NUL terminated strings::
197 * Canonical combining class::
199 * Decimal digit value::
202 * Mirrored character::
207 * ISO C and Java syntax::
208 * Classifications like in ISO C::
212 * Object oriented API::
217 * Properties as objects::
218 * Properties as functions::
222 * Grapheme cluster breaks in a string::
223 * Grapheme cluster break property::
227 * Word breaks in a string::
228 * Word break property::
232 * Decomposition of characters::
233 * Composition of characters::
234 * Normalization of strings::
235 * Normalizing comparisons::
236 * Normalization of streams::
240 * Case mappings of characters::
241 * Case mappings of strings::
242 * Case mappings of substrings::
243 * Case insensitive comparison::
252 * Reporting problems::
256 * GNU GPL:: GNU General Public License
257 * GNU LGPL:: GNU Lesser General Public License
258 * GNU FDL:: GNU Free Documentation License
264 @chapter Introduction
266 This library provides functions for manipulating Unicode strings and
267 for manipulating C strings according to the Unicode standard.
269 It consists of the following parts:
273 elementary string functions
275 conversion from/to legacy encodings
277 formatted output to strings
281 character classification and properties
283 string width when using nonproportional fonts
285 grapheme cluster breaks
289 line breaking algorithm
291 normalization (composition and decomposition)
295 regular expressions (not yet implemented)
299 @cindex value, of libunistring
300 libunistring is for you if your application involves non-trivial text
301 processing, such as upper/lower case conversions, line breaking, operations
302 on words, or more advanced analysis of text. Text provided by the user can,
303 in general, contain characters of all kinds of scripts. The text processing
304 functions provided by this library handle all scripts and all languages.
306 libunistring is for you if your application already uses the ISO C / POSIX
307 @code{<ctype.h>}, @code{<wctype.h>} functions and the text it operates on is
308 provided by the user and can be in any language.
310 libunistring is also for you if your application uses Unicode strings as
311 internal in-memory representation.
314 * Unicode:: What is Unicode?
315 * Unicode and i18n:: Unicode and internationalization
316 * Locale encodings:: What is a locale encoding?
317 * In-memory representation:: How to represent strings in memory?
318 * char * strings:: What to keep in mind with @code{char *} strings
319 * The wchar_t mess:: Why @code{wchar_t *} strings are useless
320 * Unicode strings:: How are Unicode strings represented?
327 Unicode is a standardized repertoire of characters that contains characters
328 from all scripts of the world, from Latin letters to Chinese ideographs
329 and Babylonian cuneiform glyphs. It also specifies how these characters
330 are to be rendered on a screen or on paper, and how common text processing
331 (word selection, line breaking, uppercasing of page titles etc.) is supposed
332 to behave on Unicode text.
334 Unicode also specifies three ways of storing sequences of Unicode
335 characters in a computer whose basic unit of data is an 8-bit byte:
342 Every character is represented as 1 to 4 bytes.
344 Every character is represented as 1 to 2 units of 16 bits.
345 @item UTF-32, a.k.a@. UCS-4
346 Every character is represented as 1 unit of 32 bits.
349 For encoding Unicode text in a file, UTF-8 is usually used. For encoding
350 Unicode strings in memory for a program, either of the three encoding forms
351 can be reasonably used.
353 Unicode is widely used on the web. Prior to the use of Unicode, web pages
354 were in many different encodings (ISO-8859-1 for English, French, Spanish,
355 ISO-8859-2 for Polish, ISO-8859-7 for Greek, KOI8-R for Russian, GB2312 or
356 BIG5 for Chinese, ISO-2022-JP-2 or EUC-JP or Shift_JIS for Japanese, and many
357 many others). It was next to impossible to create a document that contained
358 Chinese and Polish text in the same document. Due to the many encodings for
359 Japanese, even the processing of pure Japanese text was error prone.
364 The Unicode standard:@texnl{} @url{http://www.unicode.org/}
366 Definition of UTF-8:@texnl{} @url{http://www.rfc-editor.org/rfc/rfc3629.txt}
368 Definition of UTF-16:@texnl{} @url{http://www.rfc-editor.org/rfc/rfc2781.txt}
370 Markus Kuhn's UTF-8 and Unicode FAQ:@texnl{}
371 @url{http://www.cl.cam.ac.uk/~mgk25/unicode.html}
374 @node Unicode and i18n
375 @section Unicode and Internationalization
377 @cindex internationalization
378 Internationalization is the process of changing the source code of a program
379 so that it can meet the expectations of users in any culture, if culture
380 specific data (translations, images etc.) are provided.
382 Use of Unicode is not strictly required for internationalization, but it
383 makes internationalization much easier, because operations that need to
384 look at specific characters (like hyphenation, spell checking, or the
385 automatic conversion of double-quotes to opening and closing double-quote
386 characters) don't need to consider multiple possible encodings of the text.
388 Use of Unicode also enables multilingualization: the ability of having text
389 in multiple languages present in the same document or even in the same line
392 But use of Unicode is not everything. Internationalization usually consists
396 Use of Unicode where needed for text processing. This is what this library
399 Use of message catalogs for messages shown to the user, This is what
400 GNU gettext is about.
402 Use of locale specific conventions for date and time formats, for numeric
403 formatting, or for sorting of text. This can be done adequately with the
404 POSIX APIs and the implementation of locales in the GNU C library.
407 @node Locale encodings
408 @section Locale encodings
411 A locale is a set of cultural conventions. According to POSIX, for a program,
412 at any moment, there is one locale being designated as the ``current locale''.
413 (Actually, POSIX supports also one locale per thread, but this feature is not
414 yet universally implemented and not widely used.)
415 @cindex locale categories
416 The locale is partitioned into several aspects, called the ``categories''
417 of the locale. The main various aspects are:
420 The character encoding and the character properties. This is the
421 @code{LC_CTYPE} category.
423 The sorting rules for text. This is the @code{LC_COLLATE} category.
425 The language specific translations of messages. This is the
426 @code{LC_MESSAGES} category.
428 The formatting rules for numbers, such as the decimal separator. This is
429 the @code{LC_NUMERIC} category.
431 The formatting rules for amounts of money. This is the @code{LC_MONETARY}
434 The formatting of date and time. This is the @code{LC_TIME} category.
437 @cindex locale encoding
438 In particular, the @code{LC_CTYPE} category of the current locale determines
439 the character encoding. This is the encoding of @samp{char *} strings.
440 We also call it the ``locale encoding''. GNU libunistring has a function,
441 @func{locale_charset}, that returns a standardized (platform independent)
442 name for this encoding.
444 All locale encodings used on glibc systems are essentially ASCII compatible:
445 Most graphic ASCII characters have the same representation, as a single byte,
446 in that encoding as in ASCII.
448 Among the possible locale encodings are UTF-8 and GB18030. Both allow
449 to represent any Unicode character as a sequence of bytes. UTF-8 is used in
450 most of the world, whereas GB18030 is used in the People's Republic of China,
451 because it is backward compatible with the GB2312 encoding that was used in
452 this country earlier.
454 The legacy locale encodings, ISO-8859-15 (which supplanted ISO-8859-1 in
455 most of Europe), ISO-8859-2, KOI8-R, EUC-JP, etc., are still in use in
458 UTF-16 and UTF-32 are not used as locale encodings, because they are not
461 @node In-memory representation
462 @section Choice of in-memory representation of strings
464 There are three ways of representing strings in memory of a running
468 As @samp{char *} strings. Such strings are represented in locale encoding.
469 This approach is employed when not much text processing is done by the
470 program. When some Unicode aware processing is to be done, a string is
471 converted to Unicode on the fly and back to locale encoding afterwards.
473 As UTF-8 or UTF-16 or UTF-32 strings. This implies that conversion from
474 locale encoding to Unicode is performed on input, and in the opposite
475 direction on output. This approach is employed when the program does
476 a significant amount of text processing, or when the program has multiple
477 threads operating on the same data but in different locales.
479 As @samp{wchar_t *}, a.k.a@. ``wide strings''. This approach is misguided,
480 see @ref{The wchar_t mess}.
484 @section @samp{char *} strings
486 @cindex C string functions
487 The classical C strings, with its C library support standardized by
488 ISO C and POSIX, can be used in internationalized programs with some
489 precautions. The problem with this API is that many of the C library
490 functions for strings don't work correctly on strings in locale
491 encodings, leading to bugs that only people in some cultures of the
492 world will experience.
494 @cindex locale, multibyte
495 The first problem with the C library API is the support of multibyte
496 locales. According to the locale encoding, in general, every character
497 is represented by one or more bytes (up to 4 bytes in practice --- but
498 use @code{MB_LEN_MAX} instead of the number 4 in the code).
499 When every character is represented by only 1 byte, we speak of an
500 ``unibyte locale'', otherwise of a ``multibyte locale''. It is important
501 to realize that the majority of Unix installations nowadays use UTF-8
502 or GB18030 as locale encoding; therefore, the majority of users are
503 using multibyte locales.
506 The important fact to remember is:
508 @emph{A @samp{char} is a byte, not a character.}
514 The @code{<ctype.h>} API is useless in this context; it does not work in
517 The @posixfunc{strlen} function does not return the number of characters
518 in a string. Nor does it return the number of screen columns occupied
519 by a string after it is output. It merely returns the number of
520 @emph{bytes} occupied by a string.
522 Truncating a string, for example, with @posixfunc{strncpy}, can have the
523 effect of truncating it in the middle of a multibyte character. Such
524 a string will, when output, have a garbled character at its end, often
525 represented by a hollow box.
527 @posixfunc{strchr} and @posixfunc{strrchr} do not work with multibyte strings
528 if the locale encoding is GB18030 and the character to be searched is
531 @posixfunc{strstr} does not work with multibyte strings if the locale encoding
532 is different from UTF-8.
534 @posixfunc{strcspn}, @posixfunc{strpbrk}, @posixfunc{strspn} cannot work
535 correctly in multibyte locales: they assume the second argument is a list of
536 single-byte characters. Even in this simple case, they do not work with
537 multibyte strings if the locale encoding is GB18030 and one of the
538 characters to be searched is a digit.
540 @posixfunc{strsep} and @posixfunc{strtok_r} do not work with multibyte strings
541 unless all of the delimiter characters are ASCII characters < 0x30.
543 The @posixfunc{strcasecmp}, @posixfunc{strncasecmp}, and @posixfunc{strcasestr}
544 functions do not work with multibyte strings.
547 The workarounds can be found in GNU gnulib
548 @url{http://www.gnu.org/software/gnulib/}.
551 gnulib has modules @samp{mbchar}, @samp{mbiter}, @samp{mbuiter} that
552 represent multibyte characters and allow to iterate across a multibyte
553 string with the same ease as through a unibyte string.
555 gnulib has functions @func{mbslen} and @func{mbswidth} that can be
556 used instead of @posixfunc{strlen} when the number of characters or the
557 number of screen columns of a string is requested.
559 gnulib has functions @func{mbschr} and @func{mbsrrchr} that are
560 like @posixfunc{strchr} and @posixfunc{strrchr}, but work in multibyte locales.
562 gnulib has a function @func{mbsstr}, like @posixfunc{strstr}, but works
563 in multibyte locales.
565 gnulib has functions @func{mbscspn}, @func{mbspbrk}, @func{mbsspn}
566 that are like @posixfunc{strcspn}, @posixfunc{strpbrk}, @posixfunc{strspn}, but
567 work in multibyte locales.
569 gnulib has functions @func{mbssep} and @func{mbstok_r} that are
570 like @posixfunc{strsep} and @posixfunc{strtok_r} but work in multibyte locales.
572 gnulib has functions @func{mbscasecmp}, @func{mbsncasecmp},
573 @func{mbspcasecmp}, and @func{mbscasestr} that are like @posixfunc{strcasecmp},
574 @posixfunc{strncasecmp}, and @posixfunc{strcasestr}, but
575 work in multibyte locales. Still, the function @code{ulc_casecmp} is
576 preferable to these functions; see below.
579 The second problem with the C library API is that it has some assumptions built-in that are not valid in some languages:
582 It assumes that there are only two forms of every character: uppercase
583 and lowercase. This is not true for Croatian, where the character
584 @sc{LETTER DZ WITH CARON} comes in three forms:
585 @sc{LATIN CAPITAL LETTER DZ WITH CARON} (DZ),
586 @sc{LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON} (Dz),
587 @sc{LATIN SMALL LETTER DZ WITH CARON} (dz).
589 It assumes that uppercasing of 1 character leads to 1 character. This
590 is not true for German, where the @sc{LATIN SMALL LETTER SHARP S}, when
591 uppercased, becomes @samp{SS}.
593 It assumes that there is 1:1 mapping between uppercase and lowercase forms.
594 This is not true for the Greek sigma: @sc{GREEK CAPITAL LETTER SIGMA} is
595 the uppercase of both @sc{GREEK SMALL LETTER SIGMA} and
596 @sc{GREEK SMALL LETTER FINAL SIGMA}.
598 It assumes that the upper/lowercase mappings are position independent.
599 This is not true for the Greek sigma and the Lithuanian i.
602 The correct way to deal with this problem is
605 to provide functions for titlecasing, as well as for upper- and
608 to view case transformations as functions that operates on strings,
609 rather than on characters.
612 This is implemented in this library, through the functions declared in @code{<unicase.h>}, see @ref{unicase.h}.
614 @node The wchar_t mess
615 @section The @code{wchar_t} mess
617 @cindex wchar_t, type
618 The ISO C and POSIX standard creators made an attempt to fix the first
619 problem mentioned in the previous section. They introduced
622 a type @samp{wchar_t}, designed to encapsulate an entire character,
624 a ``wide string'' type @samp{wchar_t *}, and
626 functions declared in @code{<wctype.h>} that were meant to supplant the
627 ones in @code{<ctype.h>}.
630 Unfortunately, this API and its implementation has numerous problems:
634 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type. This
635 means that it can never accommodate an entire Unicode character. Either
636 the @code{wchar_t *} strings are limited to characters in UCS-2 (the
637 ``Basic Multilingual Plane'' of Unicode), or --- if @code{wchar_t *}
638 strings are encoded in UTF-16 --- a @code{wchar_t} represents only half
639 of a character in the worst case, making the @code{<wctype.h>} functions
643 On Solaris and FreeBSD, the @code{wchar_t} encoding is locale dependent
644 and undocumented. This means, if you want to know any property of a
645 @code{wchar_t} character, other than the properties defined by
646 @code{<wctype.h>} --- such as whether it's a dash, currency symbol,
647 paragraph separator, or similar ---, you have to convert it to
648 @code{char *} encoding first, by use of the function @posixfunc{wctomb}.
651 When you read a stream of wide characters, through the functions
652 @posixfunc{fgetwc} and @posixfunc{fgetws}, and when the input stream/file is
653 not in the expected encoding, you have no way to determine the invalid
654 byte sequence and do some corrective action. If you use these
655 functions, your program becomes ``garbage in - more garbage out'' or
656 ``garbage in - abort''.
659 As a consequence, it is better to use multibyte strings, as explained in
660 the previous section. Such multibyte strings can bypass limitations
661 of the @code{wchar_t} type, if you use functions defined in gnulib and
662 libunistring for text processing. They can also faithfully transport
663 malformed characters that were present in the input, without requiring
664 the program to produce garbage or abort.
666 @node Unicode strings
667 @section Unicode strings
669 libunistring supports Unicode strings in three representations:
670 @cindex UTF-8, strings
671 @cindex UTF-16, strings
672 @cindex UTF-32, strings
675 UTF-8 strings, through the type @samp{uint8_t *}. The units are bytes
678 UTF-16 strings, through the type @samp{uint16_t *}, The units are 16-bit
679 memory words (@code{uint16_t}).
681 UTF-32 strings, through the type @samp{uint32_t *}. The units are 32-bit
682 memory words (@code{uint32_t}).
685 As with C strings, there are two variants:
688 Unicode strings with a terminating NUL character are represented as
689 a pointer to the first unit of the string. There is a unit containing
690 a 0 value at the end. It is considered part of the string for all
691 memory allocation purposes, but is not considered part of the string
692 for all other logical purposes.
694 Unicode strings where embedded NUL characters are allowed. These
695 are represented by a pointer to the first unit and the number of units
696 (not bytes!) of the string. In this setting, there is no trailing
697 zero-valued unit used as ``end marker''.
703 This chapter explains conventions valid throughout the libunistring library.
705 @cindex argument conventions
706 Variables of type @code{char *} denote C strings in locale encoding.
707 See @ref{Locale encodings}.
709 Variables of type @code{uint8_t *} denote UTF-8 strings. Their units
712 Variables of type @code{uint16_t *} denote UTF-16 strings, without byte
713 order mark. Their units are 2-byte words.
715 Variables of type @code{uint32_t *} denote UTF-32 strings, without byte
716 order mark. Their units are 4-byte words.
718 Argument pairs @code{(@var{s}, @var{n})} denote a string
719 @code{@var{s}[0..@var{n}-1]} with exactly @var{n} units.
721 All functions with prefix @samp{ulc_} operate on C strings in locale
724 All functions with prefix @samp{u8_} operate on UTF-8 strings.
726 All functions with prefix @samp{u16_} operate on UTF-16 strings.
728 All functions with prefix @samp{u32_} operate on UTF-32 strings.
730 For every function with prefix @samp{u8_}, operating on UTF-8 strings,
731 there is also a corresponding function with prefix @samp{u16_},
732 operating on UTF-16 strings, and a corresponding function with prefix
733 @samp{u32_}, operating on UTF-32 strings. Their description is
734 analogous; in this documentation we describe only the function that
735 operates on UTF-8 strings, for brevity.
737 A declaration with a variable @var{n} denotes the three concrete
738 declarations with @var{n} = 8, @var{n} = 16, @var{n} = 32.
740 All parameters starting with @samp{str} and the parameters of
741 functions starting with @code{u8_str}/@code{u16_str}/@code{u32_str}
742 denote a NUL terminated string.
744 @cindex return value conventions
745 Error values are always returned through the @code{errno} variable,
746 usually with a return value that indicates the presence of an error
747 (NULL for functions that return an pointer, or -1 for functions that
748 return an @code{int}).
750 Functions returning a string result take a
751 @code{(@var{resultbuf}, @var{lengthp})}
752 argument pair. If @var{resultbuf} is not NULL and the result fits
753 into @code{*@var{lengthp}} units, it is put in @var{resultbuf}, and
754 @var{resultbuf} is returned. Otherwise, a freshly allocated string
755 is returned. In both cases, @code{*@var{lengthp}} is set to the
756 length (number of units) of the returned string. In case of error,
757 NULL is returned and @code{errno} is set.
759 @include unitypes.texi
761 @include uniconv.texi
762 @include unistdio.texi
763 @include uniname.texi
764 @include unictype.texi
765 @include uniwidth.texi
766 @include unigbrk.texi
767 @include uniwbrk.texi
768 @include unilbrk.texi
769 @include uninorm.texi
770 @include unicase.texi
771 @include uniregex.texi
773 @node Using the library
774 @chapter Using the library
776 This chapter explains some practical considerations, regarding the
777 installation and compiler options that are needed in order to use this
785 * Reporting problems::
789 @section Installation
792 Before you can use the library, it must be installed. First, you have to
793 make sure all dependencies are installed. They are listed in the file
797 Then you can proceed to build and install the library, as described in the
798 file @file{INSTALL}. For installation on Windows systems, please refer to
799 the file @file{README.woe32}.
801 @node Compiler options
802 @section Compiler options
804 Let's denote as @code{LIBUNISTRING_PREFIX} the value of the @samp{--prefix}
805 option that you passed to @code{configure} while installing this package.
806 If you didn't pass any @samp{--prefix} option, then the package is installed
807 in @file{/usr/local}.
809 Let's denote as @code{LIBUNISTRING_INCLUDEDIR} the directory where the
810 include files were installed. This is usually the same as
811 @code{$@{LIBUNISTRING_PREFIX@}/include}. Except that if you passed an
812 @samp{--includedir} option to @code{configure}, it is the value of that
815 Let's further denote as @code{LIBUNISTRING_LIBDIR} the directory where
816 the library itself was installed. This is the value that you passed
817 with the @samp{--libdir} option to @code{configure}, or otherwise the
818 same as @code{$@{LIBUNISTRING_PREFIX@}/lib}. Recall that when building
819 in 64-bit mode on a 64-bit GNU/Linux system that supports executables
820 in either 64-bit mode or 32-bit mode, you should have used the option
821 @code{--libdir=$@{LIBUNISTRING_PREFIX@}/lib64}.
823 @cindex compiler options
824 So that the compiler finds the include files, you have to pass it the
825 option @code{-I$@{LIBUNISTRING_INCLUDEDIR@}}.
827 So that the compiler finds the library during its linking pass, you have
828 to pass it the options @code{-L$@{LIBUNISTRING_LIBDIR@} -lunistring}.
829 On some systems, in some configurations, you also have to pass options
830 needed for linking with @code{libiconv}. The autoconf macro
831 @code{gl_LIBUNISTRING} (see @ref{Autoconf macro}) deals with this
835 @section Include files
837 Most of the include files have been presented in the introduction, see
838 @ref{Introduction}, and subsequent detailed chapters.
840 Another include file is @code{<unistring/version.h>}. It contains the
841 version number of the libunistring library.
843 @deftypevr Macro int _LIBUNISTRING_VERSION
844 This constant contains the version of libunistring that is being used
845 at compile time. It encodes the major and minor parts of the version
846 number only. These parts are encoded in the form @code{(major<<8) + minor}.
849 @deftypevr Constant int _libunistring_version
850 This constant contains the version of libunistring that is being used
851 at run time. It encodes the major and minor parts of the version
852 number only. These parts are encoded in the form @code{(major<<8) + minor}.
855 It is possible that @code{_libunistring_version} is greater than
856 @code{_LIBUNISTRING_VERSION}. This can happen when you use
857 @code{libunistring} as a shared library, and a newer, binary
858 backward-compatible version has been installed after your program
859 that uses @code{libunistring} was installed.
862 @section Autoconf macro
864 @cindex autoconf macro
865 GNU Gnulib provides an autoconf macro that tests for the availability
866 of @code{libunistring}. It is contained in the Gnulib module
867 @samp{libunistring}, see@texnl{}
868 @url{http://www.gnu.org/software/gnulib/MODULES.html#module=libunistring}.
870 @amindex gl_LIBUNISTRING
871 The macro is called @code{gl_LIBUNISTRING}. It searches for an installed
872 libunistring. If found, it sets and AC_SUBSTs @code{HAVE_LIBUNISTRING=yes}
873 and the @code{LIBUNISTRING} and @code{LTLIBUNISTRING} variables and augments
874 the @code{CPPFLAGS} variable, and defines the C macro
875 @code{HAVE_LIBUNISTRING} to 1. Otherwise, it sets and AC_SUBSTs
876 @code{HAVE_LIBUNISTRING=no} and @code{LIBUNISTRING} and @code{LTLIBUNISTRING}
879 The complexities that @code{gl_LIBUNISTRING} deals with are the following:
883 On some operating systems, in some configurations, libunistring depends
884 on @code{libiconv}, and the options for linking with libiconv must be
885 mentioned explicitly on the link command line.
888 GNU @code{libunistring}, if installed, is not necessarily already in the
889 search path (@code{CPPFLAGS} for the include file search path,
890 @code{LDFLAGS} for the library search path).
893 GNU @code{libunistring}, if installed, is not necessarily already in the
894 run time library search path. To avoid the need for setting an environment
895 variable like @code{LD_LIBRARY_PATH}, the macro adds the appropriate
896 run time search path options to the @code{LIBUNISTRING} variable. This works
900 @node Reporting problems
901 @section Reporting problems
906 If you encounter any problem, please don't hesitate to send a detailed
907 bug report to the @code{bug-libunistring@@gnu.org} mailing list. You can
908 alternatively also use the bug tracker at the project page
909 @url{https://savannah.gnu.org/projects/libunistring}.
911 Please always include the version number of this library, and a short
912 description of your operating system and compilation environment with
913 corresponding version numbers.
915 For problems that appear while building and installing @code{libunistring},
916 for which you don't find the remedy in the @file{INSTALL} file, please include
917 a description of the options that you passed to the @samp{configure} script.
919 @node More functionality
920 @chapter More advanced functionality
922 @cindex bidirectional reordering
923 For bidirectional reordering of strings, we recommend the GNU FriBidi library:
924 @url{http://www.fribidi.org/}.
927 For the rendering of Unicode strings outside of the context of a given toolkit
928 (KDE/Qt or GNOME/Gtk), we recommend the Pango library:
929 @url{http://www.pango.org/}.
935 The files of this package are covered by the licenses indicated in each
936 particular file or directory. Here is a summary:
940 The @code{libunistring} library is covered by the
941 GNU Lesser General Public License (LGPL).
942 A copy of the license is included in @ref{GNU LGPL}.
945 This manual is free documentation. It is dually licensed under the
946 GNU FDL and the GNU GPL. This means that you can redistribute this
947 manual under either of these two licenses, at your choice.
949 This manual is covered by the GNU FDL. Permission is granted to copy,
950 distribute and/or modify this document under the terms of the
951 GNU Free Documentation License (FDL), either version 1.2 of the
952 License, or (at your option) any later version published by the
953 Free Software Foundation (FSF); with no Invariant Sections, with no
954 Front-Cover Text, and with no Back-Cover Texts.
955 A copy of the license is included in @ref{GNU FDL}.
957 This manual is covered by the GNU GPL. You can redistribute it and/or
958 modify it under the terms of the GNU General Public License (GPL), either
959 version 3 of the License, or (at your option) any later version published
960 by the Free Software Foundation (FSF).
961 A copy of the license is included in @ref{GNU GPL}.
965 * GNU GPL:: GNU General Public License
966 * GNU LGPL:: GNU Lesser General Public License
967 * GNU FDL:: GNU Free Documentation License
972 @appendixsec GNU GENERAL PUBLIC LICENSE
973 @cindex GPL, GNU General Public License
974 @cindex License, GNU GPL
978 @appendixsec GNU LESSER GENERAL PUBLIC LICENSE
979 @cindex LGPL, GNU Lesser General Public License
980 @cindex License, GNU LGPL
984 @appendixsec GNU Free Documentation License
985 @cindex FDL, GNU Free Documentation License
986 @cindex License, GNU FDL
997 @c indent-tabs-mode: nil
998 @c whitespace-check-buffer-indent: nil