Annotation of embedaddon/pcre/doc/pcre16.3, revision 1.1.1.4

1.1.1.3   misho       1: .TH PCRE 3 "12 May 2013" "PCRE 8.33"
1.1       misho       2: .SH NAME
                      3: PCRE - Perl-compatible regular expressions
                      4: .sp
                      5: .B #include <pcre.h>
                      6: .
                      7: .
                      8: .SH "PCRE 16-BIT API BASIC FUNCTIONS"
                      9: .rs
                     10: .sp
1.1.1.4 ! misho      11: .nf
1.1       misho      12: .B pcre16 *pcre16_compile(PCRE_SPTR16 \fIpattern\fP, int \fIoptions\fP,
1.1.1.4 ! misho      13: .B "     const char **\fIerrptr\fP, int *\fIerroffset\fP,"
        !            14: .B "     const unsigned char *\fItableptr\fP);"
        !            15: .sp
1.1       misho      16: .B pcre16 *pcre16_compile2(PCRE_SPTR16 \fIpattern\fP, int \fIoptions\fP,
1.1.1.4 ! misho      17: .B "     int *\fIerrorcodeptr\fP,"
        !            18: .B "     const char **\fIerrptr\fP, int *\fIerroffset\fP,"
        !            19: .B "     const unsigned char *\fItableptr\fP);"
        !            20: .sp
1.1       misho      21: .B pcre16_extra *pcre16_study(const pcre16 *\fIcode\fP, int \fIoptions\fP,
1.1.1.4 ! misho      22: .B "     const char **\fIerrptr\fP);"
        !            23: .sp
1.1       misho      24: .B void pcre16_free_study(pcre16_extra *\fIextra\fP);
1.1.1.4 ! misho      25: .sp
1.1       misho      26: .B int pcre16_exec(const pcre16 *\fIcode\fP, "const pcre16_extra *\fIextra\fP,"
1.1.1.4 ! misho      27: .B "     PCRE_SPTR16 \fIsubject\fP, int \fIlength\fP, int \fIstartoffset\fP,"
        !            28: .B "     int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);"
        !            29: .sp
1.1       misho      30: .B int pcre16_dfa_exec(const pcre16 *\fIcode\fP, "const pcre16_extra *\fIextra\fP,"
1.1.1.4 ! misho      31: .B "     PCRE_SPTR16 \fIsubject\fP, int \fIlength\fP, int \fIstartoffset\fP,"
        !            32: .B "     int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP,"
        !            33: .B "     int *\fIworkspace\fP, int \fIwscount\fP);"
        !            34: .fi
1.1       misho      35: .
                     36: .
                     37: .SH "PCRE 16-BIT API STRING EXTRACTION FUNCTIONS"
                     38: .rs
                     39: .sp
1.1.1.4 ! misho      40: .nf
1.1       misho      41: .B int pcre16_copy_named_substring(const pcre16 *\fIcode\fP,
1.1.1.4 ! misho      42: .B "     PCRE_SPTR16 \fIsubject\fP, int *\fIovector\fP,"
        !            43: .B "     int \fIstringcount\fP, PCRE_SPTR16 \fIstringname\fP,"
        !            44: .B "     PCRE_UCHAR16 *\fIbuffer\fP, int \fIbuffersize\fP);"
        !            45: .sp
1.1       misho      46: .B int pcre16_copy_substring(PCRE_SPTR16 \fIsubject\fP, int *\fIovector\fP,
1.1.1.4 ! misho      47: .B "     int \fIstringcount\fP, int \fIstringnumber\fP, PCRE_UCHAR16 *\fIbuffer\fP,"
        !            48: .B "     int \fIbuffersize\fP);"
        !            49: .sp
1.1       misho      50: .B int pcre16_get_named_substring(const pcre16 *\fIcode\fP,
1.1.1.4 ! misho      51: .B "     PCRE_SPTR16 \fIsubject\fP, int *\fIovector\fP,"
        !            52: .B "     int \fIstringcount\fP, PCRE_SPTR16 \fIstringname\fP,"
        !            53: .B "     PCRE_SPTR16 *\fIstringptr\fP);"
        !            54: .sp
1.1       misho      55: .B int pcre16_get_stringnumber(const pcre16 *\fIcode\fP,
1.1.1.4 ! misho      56: .B "     PCRE_SPTR16 \fIname\fP);
        !            57: .sp
1.1       misho      58: .B int pcre16_get_stringtable_entries(const pcre16 *\fIcode\fP,
1.1.1.4 ! misho      59: .B "     PCRE_SPTR16 \fIname\fP, PCRE_UCHAR16 **\fIfirst\fP, PCRE_UCHAR16 **\fIlast\fP);"
        !            60: .sp
1.1       misho      61: .B int pcre16_get_substring(PCRE_SPTR16 \fIsubject\fP, int *\fIovector\fP,
1.1.1.4 ! misho      62: .B "     int \fIstringcount\fP, int \fIstringnumber\fP,"
        !            63: .B "     PCRE_SPTR16 *\fIstringptr\fP);"
        !            64: .sp
1.1       misho      65: .B int pcre16_get_substring_list(PCRE_SPTR16 \fIsubject\fP,
1.1.1.4 ! misho      66: .B "     int *\fIovector\fP, int \fIstringcount\fP, PCRE_SPTR16 **\fIlistptr\fP);"
        !            67: .sp
1.1       misho      68: .B void pcre16_free_substring(PCRE_SPTR16 \fIstringptr\fP);
1.1.1.4 ! misho      69: .sp
1.1       misho      70: .B void pcre16_free_substring_list(PCRE_SPTR16 *\fIstringptr\fP);
1.1.1.4 ! misho      71: .fi
1.1       misho      72: .
                     73: .
                     74: .SH "PCRE 16-BIT API AUXILIARY FUNCTIONS"
                     75: .rs
                     76: .sp
1.1.1.4 ! misho      77: .nf
1.1       misho      78: .B pcre16_jit_stack *pcre16_jit_stack_alloc(int \fIstartsize\fP, int \fImaxsize\fP);
1.1.1.4 ! misho      79: .sp
1.1       misho      80: .B void pcre16_jit_stack_free(pcre16_jit_stack *\fIstack\fP);
1.1.1.4 ! misho      81: .sp
1.1       misho      82: .B void pcre16_assign_jit_stack(pcre16_extra *\fIextra\fP,
1.1.1.4 ! misho      83: .B "     pcre16_jit_callback \fIcallback\fP, void *\fIdata\fP);"
        !            84: .sp
1.1       misho      85: .B const unsigned char *pcre16_maketables(void);
1.1.1.4 ! misho      86: .sp
1.1       misho      87: .B int pcre16_fullinfo(const pcre16 *\fIcode\fP, "const pcre16_extra *\fIextra\fP,"
1.1.1.4 ! misho      88: .B "     int \fIwhat\fP, void *\fIwhere\fP);"
        !            89: .sp
1.1       misho      90: .B int pcre16_refcount(pcre16 *\fIcode\fP, int \fIadjust\fP);
1.1.1.4 ! misho      91: .sp
1.1       misho      92: .B int pcre16_config(int \fIwhat\fP, void *\fIwhere\fP);
1.1.1.4 ! misho      93: .sp
1.1       misho      94: .B const char *pcre16_version(void);
1.1.1.4 ! misho      95: .sp
1.1       misho      96: .B int pcre16_pattern_to_host_byte_order(pcre16 *\fIcode\fP,
1.1.1.4 ! misho      97: .B "     pcre16_extra *\fIextra\fP, const unsigned char *\fItables\fP);"
        !            98: .fi
1.1       misho      99: .
                    100: .
                    101: .SH "PCRE 16-BIT API INDIRECTED FUNCTIONS"
                    102: .rs
                    103: .sp
1.1.1.4 ! misho     104: .nf
1.1       misho     105: .B void *(*pcre16_malloc)(size_t);
1.1.1.4 ! misho     106: .sp
1.1       misho     107: .B void (*pcre16_free)(void *);
1.1.1.4 ! misho     108: .sp
1.1       misho     109: .B void *(*pcre16_stack_malloc)(size_t);
1.1.1.4 ! misho     110: .sp
1.1       misho     111: .B void (*pcre16_stack_free)(void *);
1.1.1.4 ! misho     112: .sp
1.1       misho     113: .B int (*pcre16_callout)(pcre16_callout_block *);
1.1.1.4 ! misho     114: .fi
1.1       misho     115: .
                    116: .
                    117: .SH "PCRE 16-BIT API 16-BIT-ONLY FUNCTION"
                    118: .rs
                    119: .sp
1.1.1.4 ! misho     120: .nf
1.1       misho     121: .B int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *\fIoutput\fP,
1.1.1.4 ! misho     122: .B "     PCRE_SPTR16 \fIinput\fP, int \fIlength\fP, int *\fIbyte_order\fP,"
        !           123: .B "     int \fIkeep_boms\fP);"
        !           124: .fi
1.1       misho     125: .
                    126: .
                    127: .SH "THE PCRE 16-BIT LIBRARY"
                    128: .rs
                    129: .sp
                    130: Starting with release 8.30, it is possible to compile a PCRE library that
                    131: supports 16-bit character strings, including UTF-16 strings, as well as or
                    132: instead of the original 8-bit library. The majority of the work to make this
                    133: possible was done by Zoltan Herczeg. The two libraries contain identical sets
                    134: of functions, used in exactly the same way. Only the names of the functions and
                    135: the data types of their arguments and results are different. To avoid
                    136: over-complication and reduce the documentation maintenance load, most of the
                    137: PCRE documentation describes the 8-bit library, with only occasional references
                    138: to the 16-bit library. This page describes what is different when you use the
                    139: 16-bit library.
                    140: .P
                    141: WARNING: A single application can be linked with both libraries, but you must
                    142: take care when processing any particular pattern to use functions from just one
                    143: library. For example, if you want to study a pattern that was compiled with
                    144: \fBpcre16_compile()\fP, you must do so with \fBpcre16_study()\fP, not
                    145: \fBpcre_study()\fP, and you must free the study data with
                    146: \fBpcre16_free_study()\fP.
                    147: .
                    148: .
                    149: .SH "THE HEADER FILE"
                    150: .rs
                    151: .sp
                    152: There is only one header file, \fBpcre.h\fP. It contains prototypes for all the
1.1.1.3   misho     153: functions in all libraries, as well as definitions of flags, structures, error
1.1       misho     154: codes, etc.
                    155: .
                    156: .
                    157: .SH "THE LIBRARY NAME"
                    158: .rs
                    159: .sp
                    160: In Unix-like systems, the 16-bit library is called \fBlibpcre16\fP, and can
                    161: normally be accesss by adding \fB-lpcre16\fP to the command for linking an
                    162: application that uses PCRE.
                    163: .
                    164: .
                    165: .SH "STRING TYPES"
                    166: .rs
                    167: .sp
                    168: In the 8-bit library, strings are passed to PCRE library functions as vectors
                    169: of bytes with the C type "char *". In the 16-bit library, strings are passed as
                    170: vectors of unsigned 16-bit quantities. The macro PCRE_UCHAR16 specifies an
                    171: appropriate data type, and PCRE_SPTR16 is defined as "const PCRE_UCHAR16 *". In
                    172: very many environments, "short int" is a 16-bit data type. When PCRE is built,
1.1.1.3   misho     173: it defines PCRE_UCHAR16 as "unsigned short int", but checks that it really is a
                    174: 16-bit data type. If it is not, the build fails with an error message telling
                    175: the maintainer to modify the definition appropriately.
1.1       misho     176: .
                    177: .
                    178: .SH "STRUCTURE TYPES"
                    179: .rs
                    180: .sp
                    181: The types of the opaque structures that are used for compiled 16-bit patterns
                    182: and JIT stacks are \fBpcre16\fP and \fBpcre16_jit_stack\fP respectively. The
                    183: type of the user-accessible structure that is returned by \fBpcre16_study()\fP
                    184: is \fBpcre16_extra\fP, and the type of the structure that is used for passing
                    185: data to a callout function is \fBpcre16_callout_block\fP. These structures
                    186: contain the same fields, with the same names, as their 8-bit counterparts. The
                    187: only difference is that pointers to character strings are 16-bit instead of
                    188: 8-bit types.
                    189: .
                    190: .
                    191: .SH "16-BIT FUNCTIONS"
                    192: .rs
                    193: .sp
                    194: For every function in the 8-bit library there is a corresponding function in
                    195: the 16-bit library with a name that starts with \fBpcre16_\fP instead of
                    196: \fBpcre_\fP. The prototypes are listed above. In addition, there is one extra
                    197: function, \fBpcre16_utf16_to_host_byte_order()\fP. This is a utility function
                    198: that converts a UTF-16 character string to host byte order if necessary. The
                    199: other 16-bit functions expect the strings they are passed to be in host byte
                    200: order.
                    201: .P
                    202: The \fIinput\fP and \fIoutput\fP arguments of
                    203: \fBpcre16_utf16_to_host_byte_order()\fP may point to the same address, that is,
                    204: conversion in place is supported. The output buffer must be at least as long as
                    205: the input.
                    206: .P
                    207: The \fIlength\fP argument specifies the number of 16-bit data units in the
                    208: input string; a negative value specifies a zero-terminated string.
                    209: .P
                    210: If \fIbyte_order\fP is NULL, it is assumed that the string starts off in host
                    211: byte order. This may be changed by byte-order marks (BOMs) anywhere in the
                    212: string (commonly as the first character).
                    213: .P
                    214: If \fIbyte_order\fP is not NULL, a non-zero value of the integer to which it
                    215: points means that the input starts off in host byte order, otherwise the
                    216: opposite order is assumed. Again, BOMs in the string can change this. The final
                    217: byte order is passed back at the end of processing.
                    218: .P
                    219: If \fIkeep_boms\fP is not zero, byte-order mark characters (0xfeff) are copied
                    220: into the output string. Otherwise they are discarded.
                    221: .P
                    222: The result of the function is the number of 16-bit units placed into the output
                    223: buffer, including the zero terminator if the string was zero-terminated.
                    224: .
                    225: .
                    226: .SH "SUBJECT STRING OFFSETS"
                    227: .rs
                    228: .sp
1.1.1.3   misho     229: The lengths and starting offsets of subject strings must be specified in 16-bit
                    230: data units, and the offsets within subject strings that are returned by the
                    231: matching functions are in also 16-bit units rather than bytes.
1.1       misho     232: .
                    233: .
                    234: .SH "NAMED SUBPATTERNS"
                    235: .rs
                    236: .sp
                    237: The name-to-number translation table that is maintained for named subpatterns
                    238: uses 16-bit characters. The \fBpcre16_get_stringtable_entries()\fP function
                    239: returns the length of each entry in the table as the number of 16-bit data
                    240: units.
                    241: .
                    242: .
                    243: .SH "OPTION NAMES"
                    244: .rs
                    245: .sp
                    246: There are two new general option names, PCRE_UTF16 and PCRE_NO_UTF16_CHECK,
                    247: which correspond to PCRE_UTF8 and PCRE_NO_UTF8_CHECK in the 8-bit library. In
1.1.1.2   misho     248: fact, these new options define the same bits in the options word. There is a
                    249: discussion about the
                    250: .\" HTML <a href="pcreunicode.html#utf16strings">
                    251: .\" </a>
                    252: validity of UTF-16 strings
                    253: .\"
                    254: in the
                    255: .\" HREF
                    256: \fBpcreunicode\fP
                    257: .\"
                    258: page.
1.1       misho     259: .P
                    260: For the \fBpcre16_config()\fP function there is an option PCRE_CONFIG_UTF16
                    261: that returns 1 if UTF-16 support is configured, otherwise 0. If this option is
1.1.1.3   misho     262: given to \fBpcre_config()\fP or \fBpcre32_config()\fP, or if the
                    263: PCRE_CONFIG_UTF8 or PCRE_CONFIG_UTF32 option is given to \fBpcre16_config()\fP,
                    264: the result is the PCRE_ERROR_BADOPTION error.
1.1       misho     265: .
                    266: .
                    267: .SH "CHARACTER CODES"
                    268: .rs
                    269: .sp
                    270: In 16-bit mode, when PCRE_UTF16 is not set, character values are treated in the
                    271: same way as in 8-bit, non UTF-8 mode, except, of course, that they can range
                    272: from 0 to 0xffff instead of 0 to 0xff. Character types for characters less than
                    273: 0xff can therefore be influenced by the locale in the same way as before.
                    274: Characters greater than 0xff have only one case, and no "type" (such as letter
                    275: or digit).
                    276: .P
                    277: In UTF-16 mode, the character code is Unicode, in the range 0 to 0x10ffff, with
                    278: the exception of values in the range 0xd800 to 0xdfff because those are
                    279: "surrogate" values that are used in pairs to encode values greater than 0xffff.
                    280: .P
                    281: A UTF-16 string can indicate its endianness by special code knows as a
                    282: byte-order mark (BOM). The PCRE functions do not handle this, expecting strings
                    283: to be in host byte order. A utility function called
                    284: \fBpcre16_utf16_to_host_byte_order()\fP is provided to help with this (see
                    285: above).
                    286: .
                    287: .
                    288: .SH "ERROR NAMES"
                    289: .rs
                    290: .sp
                    291: The errors PCRE_ERROR_BADUTF16_OFFSET and PCRE_ERROR_SHORTUTF16 correspond to
                    292: their 8-bit counterparts. The error PCRE_ERROR_BADMODE is given when a compiled
                    293: pattern is passed to a function that processes patterns in the other
                    294: mode, for example, if a pattern compiled with \fBpcre_compile()\fP is passed to
                    295: \fBpcre16_exec()\fP.
                    296: .P
                    297: There are new error codes whose names begin with PCRE_UTF16_ERR for invalid
                    298: UTF-16 strings, corresponding to the PCRE_UTF8_ERR codes for UTF-8 strings that
                    299: are described in the section entitled
                    300: .\" HTML <a href="pcreapi.html#badutf8reasons">
                    301: .\" </a>
                    302: "Reason codes for invalid UTF-8 strings"
                    303: .\"
                    304: in the main
                    305: .\" HREF
                    306: \fBpcreapi\fP
                    307: .\"
                    308: page. The UTF-16 errors are:
                    309: .sp
                    310:   PCRE_UTF16_ERR1  Missing low surrogate at end of string
                    311:   PCRE_UTF16_ERR2  Invalid low surrogate follows high surrogate
                    312:   PCRE_UTF16_ERR3  Isolated low surrogate
1.1.1.3   misho     313:   PCRE_UTF16_ERR4  Non-character
1.1       misho     314: .
                    315: .
                    316: .SH "ERROR TEXTS"
                    317: .rs
                    318: .sp
                    319: If there is an error while compiling a pattern, the error text that is passed
                    320: back by \fBpcre16_compile()\fP or \fBpcre16_compile2()\fP is still an 8-bit
                    321: character string, zero-terminated.
                    322: .
                    323: .
                    324: .SH "CALLOUTS"
                    325: .rs
                    326: .sp
                    327: The \fIsubject\fP and \fImark\fP fields in the callout block that is passed to
                    328: a callout function point to 16-bit vectors.
                    329: .
                    330: .
                    331: .SH "TESTING"
                    332: .rs
                    333: .sp
                    334: The \fBpcretest\fP program continues to operate with 8-bit input and output
                    335: files, but it can be used for testing the 16-bit library. If it is run with the
                    336: command line option \fB-16\fP, patterns and subject strings are converted from
                    337: 8-bit to 16-bit before being passed to PCRE, and the 16-bit library functions
                    338: are used instead of the 8-bit ones. Returned 16-bit strings are converted to
1.1.1.3   misho     339: 8-bit for output. If both the 8-bit and the 32-bit libraries were not compiled,
                    340: \fBpcretest\fP defaults to 16-bit and the \fB-16\fP option is ignored.
1.1       misho     341: .P
                    342: When PCRE is being built, the \fBRunTest\fP script that is called by "make
1.1.1.3   misho     343: check" uses the \fBpcretest\fP \fB-C\fP option to discover which of the 8-bit,
                    344: 16-bit and 32-bit libraries has been built, and runs the tests appropriately.
1.1       misho     345: .
                    346: .
                    347: .SH "NOT SUPPORTED IN 16-BIT MODE"
                    348: .rs
                    349: .sp
                    350: Not all the features of the 8-bit library are available with the 16-bit
                    351: library. The C++ and POSIX wrapper functions support only the 8-bit library,
                    352: and the \fBpcregrep\fP program is at present 8-bit only.
                    353: .
                    354: .
                    355: .SH AUTHOR
                    356: .rs
                    357: .sp
                    358: .nf
                    359: Philip Hazel
                    360: University Computing Service
                    361: Cambridge CB2 3QH, England.
                    362: .fi
                    363: .
                    364: .
                    365: .SH REVISION
                    366: .rs
                    367: .sp
                    368: .nf
1.1.1.3   misho     369: Last updated: 12 May 2013
                    370: Copyright (c) 1997-2013 University of Cambridge.
1.1       misho     371: .fi

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>