Sortix cross-nightly manual
This manual documents Sortix cross-nightly. You can instead view this document in the latest official manual.
PCREUNICODE(3) | Library Functions Manual | PCREUNICODE(3) |
NAME
PCRE - Perl-compatible regular expressionsUTF-8, UTF-16, UTF-32, AND UNICODE PROPERTY SUPPORT
As well as UTF-8 support, PCRE also supports UTF-16 (from release 8.30) and UTF-32 (from release 8.32), by means of two additional libraries. They can be built as well as, or instead of, the 8-bit library.UTF-8 SUPPORT
In order process UTF-8 strings, you must build PCRE's 8-bit library with UTF support, and, in addition, you must call pcre_compile() with the PCRE_UTF8 option flag, or the pattern must start with the sequence (*UTF8) or (*UTF). When either of these is the case, both the pattern and any subject strings that are matched against it are treated as UTF-8 strings instead of strings of individual 1-byte characters.UTF-16 AND UTF-32 SUPPORT
In order process UTF-16 or UTF-32 strings, you must build PCRE's 16-bit or 32-bit library with UTF support, and, in addition, you must call pcre16_compile() or pcre32_compile() with the PCRE_UTF16 or PCRE_UTF32 option flag, as appropriate. Alternatively, the pattern must start with the sequence (*UTF16), (*UTF32), as appropriate, or (*UTF), which can be used with either library. When UTF mode is set, both the pattern and any subject strings that are matched against it are treated as UTF-16 or UTF-32 strings instead of strings of individual 16-bit or 32-bit characters.UTF SUPPORT OVERHEAD
If you compile PCRE with UTF support, but do not use it at run time, the library will be a bit bigger, but the additional run time overhead is limited to testing the PCRE_UTF[8|16|32] flag occasionally, so should not be very big.UNICODE PROPERTY SUPPORT
If PCRE is built with Unicode character property support (which implies UTF support), the escape sequences \p{..}, \P{..}, and \X can be used. The available properties that can be tested are limited to the general category properties such as Lu for an upper case letter or Nd for a decimal number, the Unicode script names such as Arabic or Han, and the derived properties Any and L&. Full lists is given in the pcrepattern and pcresyntax documentation. Only the short names for properties are supported. For example, \p{L} matches a letter. Its Perl synonym, \p{Letter}, is not supported. Furthermore, in Perl, many properties may optionally be prefixed by "Is", for compatibility with Perl 5.6. PCRE does not support this.Validity of UTF-8 strings
When you set the PCRE_UTF8 flag, the byte strings passed as patterns and subjects are (by default) checked for validity on entry to the relevant functions. The entire string is checked before any other processing takes place. From release 7.3 of PCRE, the check is according the rules of RFC 3629, which are themselves derived from the Unicode specification. Earlier releases of PCRE followed the rules of RFC 2279, which allows the full range of 31-bit values (0 to 0x7FFFFFFF). The current check allows only values in the range U+0 to U+10FFFF, excluding the surrogate area. (From release 8.33 the so-called "non-character" code points are no longer excluded because Unicode corrigendum #9 makes it clear that they should not be.)Validity of UTF-16 strings
When you set the PCRE_UTF16 flag, the strings of 16-bit data units that are passed as patterns and subjects are (by default) checked for validity on entry to the relevant functions. Values other than those in the surrogate range U+D800 to U+DFFF are independent code points. Values in the surrogate range must be used in pairs in the correct manner.Validity of UTF-32 strings
When you set the PCRE_UTF32 flag, the strings of 32-bit data units that are passed as patterns and subjects are (by default) checked for validity on entry to the relevant functions. This check allows only values in the range U+0 to U+10FFFF, excluding the surrogate area U+D800 to U+DFFF.General comments about UTF modes
1. Codepoints less than 256 can be specified in patterns by either braced or unbraced hexadecimal escape sequences (for example, \x{b3} or \xb3). Larger values have to use braced sequences.27 February 2013 | PCRE 8.33 |