#include "php_unicode.h"
#include "unicode_data.h"
+ZEND_EXTERN_MODULE_GLOBALS(mbstring)
+
/*
* A simple array of 32-bit masks for lookup.
*/
return code;
}
-MBSTRING_API unsigned long php_unicode_toupper(unsigned long code)
+MBSTRING_API unsigned long php_turkish_toupper(unsigned long code, long l, long r, int field)
+{
+ if (code == 0x0069L) {
+ return 0x0130L;
+ }
+ return case_lookup(code, l, r, field);
+}
+
+MBSTRING_API unsigned long php_turkish_tolower(unsigned long code, long l, long r, int field)
+{
+ if (code == 0x0049L) {
+ return 0x0131L;
+ }
+ return case_lookup(code, l, r, field);
+}
+
+MBSTRING_API unsigned long php_unicode_toupper(unsigned long code, enum mbfl_no_encoding enc TSRMLS_DC)
{
int field;
long l, r;
field = 2;
l = _uccase_len[0];
r = (l + _uccase_len[1]) - 3;
+
+ if (MBSTRG(current_language) == mbfl_no_language_turkish &&
+ enc == mbfl_no_encoding_8859_9) {
+ return php_turkish_toupper(code, l, r, field);
+ }
+
} else {
/*
* The character is title case.
return case_lookup(code, l, r, field);
}
-MBSTRING_API unsigned long php_unicode_tolower(unsigned long code)
+MBSTRING_API unsigned long php_unicode_tolower(unsigned long code, enum mbfl_no_encoding enc TSRMLS_DC)
{
int field;
long l, r;
field = 1;
l = 0;
r = _uccase_len[0] - 3;
+
+ if (MBSTRG(current_language) == mbfl_no_language_turkish &&
+ enc == mbfl_no_encoding_8859_9) {
+ return php_turkish_tolower(code, l, r, field);
+ }
+
} else {
/*
* The character is title case.
return case_lookup(code, l, r, field);
}
-MBSTRING_API unsigned long php_unicode_totitle(unsigned long code)
+MBSTRING_API unsigned long php_unicode_totitle(unsigned long code, enum mbfl_no_encoding enc TSRMLS_DC)
{
int field;
long l, r;
size_t unicode_len;
unsigned char *unicode_ptr;
size_t i;
+ enum mbfl_no_encoding _src_encoding = mbfl_name2no_encoding(src_encoding);
unicode = php_mb_convert_encoding(srcstr, srclen, "UCS-4BE", src_encoding, &unicode_len TSRMLS_CC);
if (unicode == NULL)
return NULL;
- unicode_ptr = unicode;
+ unicode_ptr = (unsigned char *)unicode;
switch(case_mode) {
case PHP_UNICODE_CASE_UPPER:
for (i = 0; i < unicode_len; i+=4) {
UINT32_TO_BE_ARY(&unicode_ptr[i],
- php_unicode_toupper(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+ php_unicode_toupper(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC));
}
break;
case PHP_UNICODE_CASE_LOWER:
for (i = 0; i < unicode_len; i+=4) {
UINT32_TO_BE_ARY(&unicode_ptr[i],
- php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+ php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC));
}
break;
if (mode) {
if (res) {
UINT32_TO_BE_ARY(&unicode_ptr[i],
- php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+ php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC));
} else {
mode = 0;
}
if (res) {
mode = 1;
UINT32_TO_BE_ARY(&unicode_ptr[i],
- php_unicode_totitle(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+ php_unicode_totitle(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC));
}
}
}