123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #define COMPILE_PCRE16
- #include "pcre_internal.h"
- int
- PRIV(valid_utf)(PCRE_PUCHAR string, int length, int *erroroffset)
- {
- #ifdef SUPPORT_UTF
- register PCRE_PUCHAR p;
- register pcre_uint32 c;
- if (length < 0)
- {
- for (p = string; *p != 0; p++);
- length = p - string;
- }
- for (p = string; length-- > 0; p++)
- {
- c = *p;
- if ((c & 0xf800) != 0xd800)
- {
-
- }
- else if ((c & 0x0400) == 0)
- {
-
- if (length == 0)
- {
- *erroroffset = p - string;
- return PCRE_UTF16_ERR1;
- }
- p++;
- length--;
- if ((*p & 0xfc00) != 0xdc00)
- {
- *erroroffset = p - string;
- return PCRE_UTF16_ERR2;
- }
- }
- else
- {
-
- *erroroffset = p - string;
- return PCRE_UTF16_ERR3;
- }
- }
- #else
- (void)(string);
- (void)(length);
- (void)(erroroffset);
- #endif
- return PCRE_UTF16_ERR0;
- }
|