From: Rui Hirokawa Date: Tue, 2 Jul 2002 15:26:25 +0000 (+0000) Subject: fixed shift_jis character corruption including 0x5c as second byte. X-Git-Tag: php-4.2.3RC1~88 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64d489900af90cb07d340dad167a656f0b302a72;p=php fixed shift_jis character corruption including 0x5c as second byte. --- diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index bc8175fc21..9d9a5cf3b4 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -1142,6 +1142,28 @@ SAPI_POST_HANDLER_FUNC(php_mbstr_post_handler) } #endif +#define IS_SJIS1(c) ((((c)>=0x81 && (c)<=0x9f) || ((c)>=0xe0 && (c)<=0xf5)) ? 1 : 0) +#define IS_SJIS2(c) ((((c)>=0x40 && (c)<=0x7e) || ((c)>=0x80 && (c)<=0xfc)) ? 1 : 0) + +char *mbstr_strrchr(const char *s, char c){ + unsigned char *p = (unsigned char *)s, *last = NULL; + while(*p++) { + if (*p == c) { + last = p; + } + if (*p == '\0'){ + break; + } + if (IS_SJIS1(*p) && IS_SJIS2(*(p+1))) { + p++; + } + } + return last; +} + + + + /* http input processing */ void mbstr_treat_data(int arg, char *str, zval* destArray TSRMLS_DC) {