Characters in the "Surrogate Area" of Unicode are reserved for use by UTF-16, where they are used in pairs to encode codepoints with values greater than 0xFFFF. The code points that are encoded by UTF-16 pairs are available independently in the UTF-8 and UTF-32 encodings. (In other words, the whole surrogate thing is a fudge for UTF-16 which unfortunately messes up UTF-8 and UTF-32.)
If an invalid UTF-8 string is passed to PCRE, an error return is given. At compile time, the only additional information is the offset to the first byte of the failing character. The run-time functions pcre_exec() and pcre_dfa_exec() also pass back this information, as well as a more detailed reason code if the caller has provided memory in which to do this.
In some situations, you may already know that your strings are valid, and therefore want to skip these checks in order to improve performance, for example in the case of a long subject string that is being scanned repeatedly. If you set the PCRE_NO_UTF8_CHECK flag at compile time or at run time, PCRE assumes that the pattern or subject it is given (respectively) contains only valid UTF-8 codes. In this case, it does not diagnose an invalid UTF-8 string.
Note that passing PCRE_NO_UTF8_CHECK to pcre_compile() just disables the check for the pattern; it does not also apply to subject strings. If you want to disable the check for a subject string you must pass this option to pcre_exec() or pcre_dfa_exec().
If you pass an invalid UTF-8 string when PCRE_NO_UTF8_CHECK is set, the result
is undefined and your program may crash.
.
.
HTML <a name="utf16strings"></a>
If an invalid UTF-16 string is passed to PCRE, an error return is given. At compile time, the only additional information is the offset to the first data unit of the failing character. The run-time functions pcre16_exec() and pcre16_dfa_exec() also pass back this information, as well as a more detailed reason code if the caller has provided memory in which to do this.
In some situations, you may already know that your strings are valid, and
therefore want to skip these checks in order to improve performance. If you set
the PCRE_NO_UTF16_CHECK flag at compile time or at run time, PCRE assumes that
the pattern or subject it is given (respectively) contains only valid UTF-16
sequences. In this case, it does not diagnose an invalid UTF-16 string.
However, if an invalid string is passed, the result is undefined.
.
.
HTML <a name="utf32strings"></a>
If an invalid UTF-32 string is passed to PCRE, an error return is given. At compile time, the only additional information is the offset to the first data unit of the failing character. The run-time functions pcre32_exec() and pcre32_dfa_exec() also pass back this information, as well as a more detailed reason code if the caller has provided memory in which to do this.
In some situations, you may already know that your strings are valid, and therefore want to skip these checks in order to improve performance. If you set the PCRE_NO_UTF32_CHECK flag at compile time or at run time, PCRE assumes that the pattern or subject it is given (respectively) contains only valid UTF-32 sequences. In this case, it does not diagnose an invalid UTF-32 string. However, if an invalid string is passed, the result is undefined. . .
2. Octal numbers up to \e777 are recognized, and in UTF-8 mode they match two-byte characters for values greater than \e177.
3. Repeat quantifiers apply to complete UTF characters, not to individual data units, for example: \ex{100}{3}.
4. The dot metacharacter matches one UTF character instead of a single data unit.
5. The escape sequence \eC can be used to match a single byte in UTF-8 mode, or
a single 16-bit data unit in UTF-16 mode, or a single 32-bit data unit in
UTF-32 mode, but its use can lead to some strange effects because it breaks up
multi-unit characters (see the description of \eC in the
HREF
pcrepattern
documentation). The use of \eC is not supported in the alternative matching
function pcre[16|32]_dfa_exec(), nor is it supported in UTF mode by the
JIT optimization of pcre[16|32]_exec(). If JIT optimization is requested
for a UTF pattern that contains \eC, it will not succeed, and so the matching
will be carried out by the normal interpretive function.
6. The character escapes \eb, \eB, \ed, \eD, \es, \eS, \ew, and \eW correctly
test characters of any code value, but, by default, the characters that PCRE
recognizes as digits, spaces, or word characters remain the same set as in
non-UTF mode, all with values less than 256. This remains true even when PCRE
is built to include Unicode property support, because to do otherwise would
slow down PCRE in many common cases. Note in particular that this applies to
\eb and \eB, because they are defined in terms of \ew and \eW. If you really
want to test for a wider sense of, say, "digit", you can use explicit Unicode
property tests such as \ep{Nd}. Alternatively, if you set the PCRE_UCP option,
the way that the character escapes work is changed so that Unicode properties
are used to determine which characters match. There are more details in the
section on
HTML <a href="pcrepattern.html#genericchartypes">
</a>
generic character types
in the
HREF
pcrepattern
documentation.
7. Similarly, characters that match the POSIX named character classes are all low-valued characters, unless the PCRE_UCP option is set.
8. However, the horizontal and vertical white space matching escapes (\eh, \eH, \ev, and \eV) do match all the appropriate Unicode characters, whether or not PCRE_UCP is set.
9. Case-insensitive matching applies only to characters whose values are less than 128, unless PCRE is built with Unicode property support. A few Unicode characters such as Greek sigma have more than two codepoints that are case-equivalent. Up to and including PCRE release 8.31, only one-to-one case mappings were supported, but later releases (with Unicode property support) do treat as case-equivalent all versions of characters such as Greek sigma. . .
Philip Hazel University Computing Service Cambridge CB2 3QH, England.. .
Last updated: 27 February 2013 Copyright (c) 1997-2013 University of Cambridge.