123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #define COMPILE_PCRE32
- #include "pcre_internal.h"
- #ifdef SUPPORT_UTF
- static pcre_uint32
- swap_uint32(pcre_uint32 value)
- {
- return ((value & 0x000000ff) << 24) |
- ((value & 0x0000ff00) << 8) |
- ((value & 0x00ff0000) >> 8) |
- (value >> 24);
- }
- #endif
- int
- pcre32_utf32_to_host_byte_order(PCRE_UCHAR32 *output, PCRE_SPTR32 input,
- int length, int *host_byte_order, int keep_boms)
- {
- #ifdef SUPPORT_UTF
- int host_bo = host_byte_order != NULL ? *host_byte_order : 1;
- pcre_uchar *optr = (pcre_uchar *)output;
- const pcre_uchar *iptr = (const pcre_uchar *)input;
- const pcre_uchar *end;
- register pcre_uchar c;
- if (length < 0)
- end = iptr + STRLEN_UC(iptr) + 1;
- else
- end = iptr + length;
- while (iptr < end)
- {
- c = *iptr++;
- if (c == 0x0000feffu || c == 0xfffe0000u)
- {
-
- host_bo = c == 0x0000feffu;
- if (keep_boms != 0)
- *optr++ = 0x0000feffu;
- }
- else
- *optr++ = host_bo ? c : swap_uint32(c);
- }
- if (host_byte_order != NULL)
- *host_byte_order = host_bo;
- #else
- (void)(output);
- (void)(input);
- (void)(keep_boms);
- (void)(host_byte_order);
- #endif
- return length;
- }
|