42static bool prop_lookup(
unsigned long code,
unsigned long n)
44 long l = _ucprop_offsets[
n];
45 long r = _ucprop_offsets[
n + 1] - 1;
51 long m = (l + r) >> 1;
53 if (code > _ucprop_ranges[m + 1])
55 else if (code < _ucprop_ranges[m])
66 return prop_lookup(code, prop);
76 int prop = va_arg(va,
int);
81 if (prop_lookup(code, prop)) {
91static inline unsigned mph_hash(
unsigned d,
unsigned x) {
93 x = ((x >> 16) ^ x) * 0x45d9f3b;
97#define CODE_NOT_FOUND ((unsigned) -1)
99static inline unsigned mph_lookup(
101 const short *g_table,
unsigned g_table_size,
102 const unsigned *table,
unsigned table_size)
104 short g = g_table[mph_hash(0, code) % g_table_size];
110 idx = mph_hash(g, code) % table_size;
113 if (table[2*idx] == code) {
114 return table[2*idx + 1];
119#define CASE_LOOKUP(code, type) \
120 mph_lookup(code, _uccase_##type##_g, _uccase_##type##_g_size, \
121 _uccase_##type##_table, _uccase_##type##_table_size)
123static unsigned php_unicode_toupper_raw(
unsigned code,
const mbfl_encoding *enc)
129 if (code >= 0x61 && code <= 0x7A) {
145static unsigned php_unicode_tolower_raw(
unsigned code,
const mbfl_encoding *enc)
151 if (code >= 0x41 && code <= 0x5A) {
170static unsigned php_unicode_totitle_raw(
unsigned code,
const mbfl_encoding *enc)
178 return php_unicode_toupper_raw(code, enc);
181static unsigned php_unicode_tofold_raw(
unsigned code,
const mbfl_encoding *enc)
185 if (code >= 0x41 && code <= 0x5A) {
204static inline unsigned php_unicode_tolower_simple(
unsigned code,
const mbfl_encoding *enc) {
205 code = php_unicode_tolower_raw(code, enc);
207 return _uccase_extra_table[code & 0xffffff];
211static inline unsigned php_unicode_toupper_simple(
unsigned code,
const mbfl_encoding *enc) {
212 code = php_unicode_toupper_raw(code, enc);
214 return _uccase_extra_table[code & 0xffffff];
218static inline unsigned php_unicode_totitle_simple(
unsigned code,
const mbfl_encoding *enc) {
219 code = php_unicode_totitle_raw(code, enc);
221 return _uccase_extra_table[code & 0xffffff];
225static inline unsigned php_unicode_tofold_simple(
unsigned code,
const mbfl_encoding *enc) {
226 code = php_unicode_tofold_raw(code, enc);
228 return _uccase_extra_table[code & 0xffffff];
233static uint32_t *emit_special_casing_sequence(uint32_t w, uint32_t *
out)
235 unsigned int len = w >> 24;
236 const unsigned int *
p = &_uccase_extra_table[w & 0xFFFFFF];
246 uint32_t wchar_buf[64];
249 size_t out_len =
encoding->to_wchar(&in, &in_len, wchar_buf, 64, &
state);
251 for (
unsigned int i = 0; i < out_len; i++) {
252 uint32_t w = wchar_buf[i];
266static bool scan_back_for_cased_letter(uint32_t *
begin, uint32_t *
end)
286 uint32_t wchar_buf[64], converted_buf[192];
287 unsigned int state = 0, title_mode = 0;
288 unsigned char *in = (
unsigned char*)srcstr;
291 uint32_t *converted_end =
NULL;
294 mb_convert_buf_init(&
buf, in_len + 1, illegal_substchar, illegal_mode);
297 size_t out_len = src_encoding->
to_wchar(&in, &in_len, wchar_buf, 64, &
state);
299 uint32_t *
p = converted_buf;
304 for (
size_t i = 0; i < out_len; i++) {
305 uint32_t w = wchar_buf[i];
306 *
p++ = (
UNEXPECTED(w > 0xFFFFFF)) ? w : php_unicode_toupper_simple(w, src_encoding);
311 for (
size_t i = 0; i < out_len; i++) {
312 uint32_t w = wchar_buf[i];
313 *
p++ = (
UNEXPECTED(w > 0xFFFFFF)) ? w : php_unicode_tolower_simple(w, src_encoding);
318 for (
size_t i = 0; i < out_len; i++) {
319 uint32_t w = wchar_buf[i];
320 *
p++ = (
UNEXPECTED(w > 0xFFFFFF)) ? w : php_unicode_tofold_simple(w, src_encoding);
325 for (
size_t i = 0; i < out_len; i++) {
326 uint32_t w = wchar_buf[i];
331 *
p++ = title_mode ? php_unicode_tolower_simple(w, src_encoding) : php_unicode_totitle_simple(w, src_encoding);
339 for (
size_t i = 0; i < out_len; i++) {
340 uint32_t w = wchar_buf[i];
345 w = php_unicode_toupper_raw(w, src_encoding);
347 p = emit_special_casing_sequence(w,
p);
355 for (
size_t i = 0; i < out_len; i++) {
356 uint32_t w = wchar_buf[i];
398 w = php_unicode_tolower_raw(w, src_encoding);
400 p = emit_special_casing_sequence(w,
p);
408 for (
size_t i = 0; i < out_len; i++) {
409 uint32_t w = wchar_buf[i];
414 w = php_unicode_tofold_raw(w, src_encoding);
416 p = emit_special_casing_sequence(w,
p);
424 for (
size_t i = 0; i < out_len; i++) {
425 uint32_t w = wchar_buf[i];
448 w2 = php_unicode_tolower_raw(w, src_encoding);
450 w2 = php_unicode_totitle_raw(w, src_encoding);
453 p = emit_special_casing_sequence(w2,
p);
469 dst_encoding->
from_wchar(converted_buf,
p - converted_buf, &
buf, !in_len);
472 return mb_convert_buf_result(&
buf, dst_encoding);
zend_ffi_ctype_name_buf buf
const mbfl_encoding mbfl_encoding_8859_9
unsigned const char * end
xmlCharEncodingHandlerPtr encoding
MBSTRING_API zend_string * php_unicode_convert_case(php_case_mode case_mode, const char *srcstr, size_t in_len, const mbfl_encoding *src_encoding, const mbfl_encoding *dst_encoding, int illegal_mode, uint32_t illegal_substchar)
MBSTRING_API bool php_unicode_is_prop1(unsigned long code, int prop)
#define CASE_LOOKUP(code, type)
MBSTRING_API bool php_unicode_is_prop(unsigned long code,...)
#define php_unicode_is_cased(cc)
#define php_unicode_is_case_ignorable(cc)
@ PHP_UNICODE_CASE_LOWER_SIMPLE
@ PHP_UNICODE_CASE_FOLD_SIMPLE
@ PHP_UNICODE_CASE_UPPER_SIMPLE
@ PHP_UNICODE_CASE_TITLE_SIMPLE
mb_from_wchar_fn from_wchar
#define ZEND_EXTERN_MODULE_GLOBALS(module_name)
struct _zend_string zend_string
#define EMPTY_SWITCH_DEFAULT_CASE()
#define UNEXPECTED(condition)