/[pcre]/code/trunk/doc/html/pcreunicode.html
ViewVC logotype

Diff of /code/trunk/doc/html/pcreunicode.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1193 by ph10, Sat Jun 2 11:03:06 2012 UTC revision 1194 by ph10, Wed Oct 31 17:42:29 2012 UTC
# Line 20  From Release 8.30, in addition to its pr Line 20  From Release 8.30, in addition to its pr
20  supports UTF-16 by means of a separate 16-bit library. This can be built as  supports UTF-16 by means of a separate 16-bit library. This can be built as
21  well as, or instead of, the 8-bit library.  well as, or instead of, the 8-bit library.
22  </P>  </P>
23    <P>
24    From Release 8.32, in addition to its previous UTF-8 and UTF-16 support,
25    PCRE also supports UTF-32 by means of a separate 32-bit library. This can be
26    built as well as, or instead of, the 8-bit and 16-bit libraries.
27    </P>
28  <br><b>  <br><b>
29  UTF-8 SUPPORT  UTF-8 SUPPORT
30  </b><br>  </b><br>
# Line 45  strings that are matched against it are Line 50  strings that are matched against it are
50  strings of 16-bit characters.  strings of 16-bit characters.
51  </P>  </P>
52  <br><b>  <br><b>
53    UTF-32 SUPPORT
54    </b><br>
55    <P>
56    In order process UTF-32 strings, you must build PCRE's 32-bit library with UTF
57    support, and, in addition, you must call
58    <a href="pcre_compile.html"><b>pcre32_compile()</b></a>
59    with the PCRE_UTF32 option flag, or the pattern must start with the sequence
60    (*UTF32). When either of these is the case, both the pattern and any subject
61    strings that are matched against it are treated as UTF-32 strings instead of
62    strings of 32-bit characters.
63    </P>
64    <br><b>
65  UTF SUPPORT OVERHEAD  UTF SUPPORT OVERHEAD
66  </b><br>  </b><br>
67  <P>  <P>
68  If you compile PCRE with UTF support, but do not use it at run time, the  If you compile PCRE with UTF support, but do not use it at run time, the
69  library will be a bit bigger, but the additional run time overhead is limited  library will be a bit bigger, but the additional run time overhead is limited
70  to testing the PCRE_UTF8/16 flag occasionally, so should not be very big.  to testing the PCRE_UTF[8|16|32] flag occasionally, so should not be very big.
71  </P>  </P>
72  <br><b>  <br><b>
73  UNICODE PROPERTY SUPPORT  UNICODE PROPERTY SUPPORT
# Line 79  place. From release 7.3 of PCRE, the che Line 96  place. From release 7.3 of PCRE, the che
96  which are themselves derived from the Unicode specification. Earlier releases  which are themselves derived from the Unicode specification. Earlier releases
97  of PCRE followed the rules of RFC 2279, which allows the full range of 31-bit  of PCRE followed the rules of RFC 2279, which allows the full range of 31-bit
98  values (0 to 0x7FFFFFFF). The current check allows only values in the range U+0  values (0 to 0x7FFFFFFF). The current check allows only values in the range U+0
99  to U+10FFFF, excluding U+D800 to U+DFFF.  to U+10FFFF, excluding the surrogate area, and the non-characters.
100  </P>  </P>
101  <P>  <P>
102  The excluded code points are the "Surrogate Area" of Unicode. They are reserved  Excluded code points are the "Surrogate Area" of Unicode. They are reserved
103  for use by UTF-16, where they are used in pairs to encode codepoints with  for use by UTF-16, where they are used in pairs to encode codepoints with
104  values greater than 0xFFFF. The code points that are encoded by UTF-16 pairs  values greater than 0xFFFF. The code points that are encoded by UTF-16 pairs
105  are available independently in the UTF-8 encoding. (In other words, the whole  are available independently in the UTF-8 encoding. (In other words, the whole
106  surrogate thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)  surrogate thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)
107  </P>  </P>
108  <P>  <P>
109    Also excluded are the "Non-Characters" code points, which are U+FDD0 to U+FDEF
110    and the last two code points in each plane, U+??FFFE and U+??FFFF.
111    </P>
112    <P>
113  If an invalid UTF-8 string is passed to PCRE, an error return is given. At  If an invalid UTF-8 string is passed to PCRE, an error return is given. At
114  compile time, the only additional information is the offset to the first byte  compile time, the only additional information is the offset to the first byte
115  of the failing character. The run-time functions <b>pcre_exec()</b> and  of the failing character. The run-time functions <b>pcre_exec()</b> and
# Line 134  U+D800 to U+DFFF are independent code po Line 155  U+D800 to U+DFFF are independent code po
155  must be used in pairs in the correct manner.  must be used in pairs in the correct manner.
156  </P>  </P>
157  <P>  <P>
158    Excluded are the "Non-Characters" code points, which are U+FDD0 to U+FDEF
159    and the last two code points in each plane, U+??FFFE and U+??FFFF.
160    </P>
161    <P>
162  If an invalid UTF-16 string is passed to PCRE, an error return is given. At  If an invalid UTF-16 string is passed to PCRE, an error return is given. At
163  compile time, the only additional information is the offset to the first data  compile time, the only additional information is the offset to the first data
164  unit of the failing character. The run-time functions <b>pcre16_exec()</b> and  unit of the failing character. The run-time functions <b>pcre16_exec()</b> and
# Line 146  therefore want to skip these checks in o Line 171  therefore want to skip these checks in o
171  the PCRE_NO_UTF16_CHECK flag at compile time or at run time, PCRE assumes that  the PCRE_NO_UTF16_CHECK flag at compile time or at run time, PCRE assumes that
172  the pattern or subject it is given (respectively) contains only valid UTF-16  the pattern or subject it is given (respectively) contains only valid UTF-16
173  sequences. In this case, it does not diagnose an invalid UTF-16 string.  sequences. In this case, it does not diagnose an invalid UTF-16 string.
174    <a name="utf32strings"></a></P>
175    <br><b>
176    Validity of UTF-32 strings
177    </b><br>
178    <P>
179    When you set the PCRE_UTF32 flag, the strings of 32-bit data units that are
180    passed as patterns and subjects are (by default) checked for validity on entry
181    to the relevant functions.  This check allows only values in the range U+0
182    to U+10FFFF, excluding the surrogate area U+D800 to U+DFFF, and the
183    "Non-Characters" code points, which are U+FDD0 to U+FDEF and the last two
184    characters in each plane, U+??FFFE and U+??FFFF.
185    </P>
186    <P>
187    If an invalid UTF-32 string is passed to PCRE, an error return is given. At
188    compile time, the only additional information is the offset to the first data
189    unit of the failing character. The run-time functions <b>pcre32_exec()</b> and
190    <b>pcre32_dfa_exec()</b> also pass back this information, as well as a more
191    detailed reason code if the caller has provided memory in which to do this.
192    </P>
193    <P>
194    In some situations, you may already know that your strings are valid, and
195    therefore want to skip these checks in order to improve performance. If you set
196    the PCRE_NO_UTF32_CHECK flag at compile time or at run time, PCRE assumes that
197    the pattern or subject it is given (respectively) contains only valid UTF-32
198    sequences. In this case, it does not diagnose an invalid UTF-32 string.
199    </P>
200    <P>
201    UTF-32 only uses the lowest 21 bits of the 32 bit characters, and the
202    application may use the upper bits for internal purposes. To allow you to
203    pass these strings to PCRE unmodified (thus avoiding the costly operation of
204    creating a copy of the string with the upper bits masked), PCRE accepts
205    these 32-bit character strings as-is, but only uses the lowest 21 bits for
206    matching, if you pass the PCRE_NO_UTF32_CHECK flag to <b>pcre32_exec()</b> and
207    <b>pcre32_dfa_exec()</b>. However, in this situation, you will have to apply
208    your own validity check, and avoid the use of JIT optimization.
209    (The latter restriction may be lifter in a later version of PCRE.)
210  </P>  </P>
211  <br><b>  <br><b>
212  General comments about UTF modes  General comments about UTF modes
# Line 169  unit. Line 230  unit.
230  </P>  </P>
231  <P>  <P>
232  5. The escape sequence \C can be used to match a single byte in UTF-8 mode, or  5. The escape sequence \C can be used to match a single byte in UTF-8 mode, or
233  a single 16-bit data unit in UTF-16 mode, but its use can lead to some strange  a single 16-bit data unit in UTF-16 mode, or a single 32-bit data unit in
234  effects because it breaks up multi-unit characters (see the description of \C  UTF-32 mode, but its use can lead to some strange effects because it breaks up
235  in the  multi-unit characters (see the description of \C in the
236  <a href="pcrepattern.html"><b>pcrepattern</b></a>  <a href="pcrepattern.html"><b>pcrepattern</b></a>
237  documentation). The use of \C is not supported in the alternative matching  documentation). The use of \C is not supported in the alternative matching
238  function <b>pcre[16]_dfa_exec()</b>, nor is it supported in UTF mode by the JIT  function <b>pcre[16|32]_dfa_exec()</b>, nor is it supported in UTF mode by the JIT
239  optimization of <b>pcre[16]_exec()</b>. If JIT optimization is requested for a  optimization of <b>pcre[16|32]_exec()</b>. If JIT optimization is requested for a
240  UTF pattern that contains \C, it will not succeed, and so the matching will  UTF pattern that contains \C, it will not succeed, and so the matching will
241  be carried out by the normal interpretive function.  be carried out by the normal interpretive function.
242  </P>  </P>
# Line 208  PCRE_UCP is set. Line 269  PCRE_UCP is set.
269  </P>  </P>
270  <P>  <P>
271  9. Case-insensitive matching applies only to characters whose values are less  9. Case-insensitive matching applies only to characters whose values are less
272  than 128, unless PCRE is built with Unicode property support. Even when Unicode  than 128, unless PCRE is built with Unicode property support. A few Unicode
273  property support is available, PCRE still uses its own character tables when  characters such as Greek sigma have more than two codepoints that are
274  checking the case of low-valued characters, so as not to degrade performance.  case-equivalent. Up to and including PCRE release 8.31, only one-to-one case
275  The Unicode property information is used only for characters with higher  mappings were supported, but later releases (with Unicode property support) do
276  values. Furthermore, PCRE supports case-insensitive matching only when there is  treat as case-equivalent all versions of characters such as Greek sigma.
 a one-to-one mapping between a letter's cases. There are a small number of  
 many-to-one mappings in Unicode; these are not supported by PCRE.  
277  </P>  </P>
278  <br><b>  <br><b>
279  AUTHOR  AUTHOR
# Line 231  Cambridge CB2 3QH, England. Line 290  Cambridge CB2 3QH, England.
290  REVISION  REVISION
291  </b><br>  </b><br>
292  <P>  <P>
293  Last updated: 14 April 2012  Last updated: 25 September 2012
294  <br>  <br>
295  Copyright &copy; 1997-2012 University of Cambridge.  Copyright &copy; 1997-2012 University of Cambridge.
296  <br>  <br>

Legend:
Removed from v.1193  
changed lines
  Added in v.1194

  ViewVC Help
Powered by ViewVC 1.1.5