PHP_ARG_ENABLE(mbregex, whether to enable multibyte regex support,
[ --enable-mbregex Enable multibyte regex support], yes)
-PHP_ARG_ENABLE(mbstring, whether to enable multibyte string support,
+PHP_ARG_WITH(mbstring, whether to enable multibyte string support,
[ --disable-mbstring Disable multibyte string support], yes)
if test "$PHP_MBSTRING" != "no"; then
MBFL_ENCTYPE_MBCS
};
+static mbfl_encoding mbfl_encoding_2022kr = {
+ mbfl_no_encoding_2022kr,
+ "ISO-2022-KR",
+ "ISO-2022-KR",
+ NULL,
+ NULL,
+ MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE
+};
+
#endif /* HAVE_MBSTR_KR */
static const char *mbfl_encoding_cp1252_aliases[] = {"cp1252", NULL};
#if defined(HAVE_MBSTR_KR)
&mbfl_encoding_euc_kr,
&mbfl_encoding_uhc,
+ &mbfl_encoding_2022kr,
#endif
#if defined(HAVE_MBSTR_RU)
&mbfl_encoding_cp1251,
#if defined(HAVE_MBSTR_KR)
static int mbfl_filt_ident_euckr(int c, mbfl_identify_filter *filter TSRMLS_DC);
static int mbfl_filt_ident_uhc(int c, mbfl_identify_filter *filter TSRMLS_DC);
+static int mbfl_filt_ident_2022kr(int c, mbfl_identify_filter *filter TSRMLS_DC);
#endif /* HAVE_MBSTR_KR */
#if defined(HAVE_MBSTR_RU)
mbfl_filt_conv_common_dtor,
mbfl_filt_conv_wchar_uhc,
mbfl_filt_conv_common_flush };
+
+static struct mbfl_convert_vtbl vtbl_wchar_2022kr = {
+ mbfl_no_encoding_wchar,
+ mbfl_no_encoding_2022kr,
+ mbfl_filt_conv_common_ctor,
+ mbfl_filt_conv_common_dtor,
+ mbfl_filt_conv_wchar_2022kr,
+ mbfl_filt_conv_any_2022kr_flush };
+
+static struct mbfl_convert_vtbl vtbl_2022kr_wchar = {
+ mbfl_no_encoding_2022kr,
+ mbfl_no_encoding_wchar,
+ mbfl_filt_conv_common_ctor,
+ mbfl_filt_conv_common_dtor,
+ mbfl_filt_conv_2022kr_wchar,
+ mbfl_filt_conv_common_flush };
+
#endif /* HAVE_MBSTR_KR */
#if defined(HAVE_MBSTR_RU)
&vtbl_wchar_euckr,
&vtbl_uhc_wchar,
&vtbl_wchar_uhc,
+ &vtbl_2022kr_wchar,
+ &vtbl_wchar_2022kr,
#endif
#if defined(HAVE_MBSTR_RU)
&vtbl_cp1251_wchar,
mbfl_filt_ident_common_ctor,
mbfl_filt_ident_common_dtor,
mbfl_filt_ident_uhc };
+
+static struct mbfl_identify_vtbl vtbl_identify_2022kr = {
+ mbfl_no_encoding_2022kr,
+ mbfl_filt_ident_common_ctor,
+ mbfl_filt_ident_common_dtor,
+ mbfl_filt_ident_2022kr };
+
#endif /* HAVE_MBSTR_KR */
#if defined(HAVE_MBSTR_RU)
#if defined(HAVE_MBSTR_KR)
&vtbl_identify_euckr,
&vtbl_identify_uhc,
+ &vtbl_identify_2022kr,
#endif
#if defined(HAVE_MBSTR_RU)
&vtbl_identify_cp1251,
return c;
}
+static int
+mbfl_filt_ident_2022kr(int c, mbfl_identify_filter *filter TSRMLS_DC)
+{
+retry:
+ switch (filter->status & 0xf) {
+/* case 0x00: ASCII */
+/* case 0x10: KSC5601 mode */
+/* case 0x20: KSC5601 DBCS */
+/* case 0x40: KSC5601 SBCS */
+ case 0:
+ if (!(filter->status & 0x10)) {
+ if (c == 0x1b)
+ filter->status += 2;
+ } else if (filter->status == 0x20 && c > 0x20 && c < 0x7f) { /* kanji first char */
+ filter->status += 1;
+ } else if (c >= 0 && c < 0x80) { /* latin, CTLs */
+ ;
+ } else {
+ filter->flag = 1; /* bad */
+ }
+ break;
+
+/* case 0x21: KSC5601 second char */
+ case 1:
+ filter->status &= ~0xf;
+ if (c < 0x21 || c > 0x7e) { /* bad */
+ filter->flag = 1;
+ }
+ break;
+
+ /* ESC */
+ case 2:
+ if (c == 0x24) { /* '$' */
+ filter->status++;
+ } else {
+ filter->flag = 1; /* bad */
+ filter->status &= ~0xf;
+ goto retry;
+ }
+ break;
+
+ /* ESC $ */
+ case 3:
+ if (c == 0x29) { /* ')' */
+ filter->status++;
+ } else {
+ filter->flag = 1; /* bad */
+ filter->status &= ~0xf;
+ goto retry;
+ }
+ break;
+
+ /* ESC $) */
+ case 5:
+ if (c == 0x43) { /* 'C' */
+ filter->status = 0x10;
+ } else {
+ filter->flag = 1; /* bad */
+ filter->status &= ~0xf;
+ goto retry;
+ }
+ break;
+
+ default:
+ filter->status = 0;
+ break;
+ }
+
+ return c;
+}
+
#endif /* HAVE_MBSTR_KR */
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Den V. Tsopa <tdv@edisoft.ru> |
+ +----------------------------------------------------------------------+
+ */
+
/*
* "russian code filter and converter"
*/
+
+/* $Id$ */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#endif /* HAVE_MBSTR_TW */
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Den V. Tsopa <tdv@edisoft.ru> |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
#ifndef MBFL_MBFILTER_RU_H
#define MBFL_MBFILTER_RU_H
int mbfl_filt_conv_wchar_koi8r(int c, mbfl_convert_filter *filter TSRMLS_DC);
#endif /* MBFL_MBFILTER_RU_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
#include "mbregex.h"
#endif
+#include "mbfilter.h"
+
#if defined(HAVE_MBSTR_JA)
static const enum mbfl_no_encoding php_mbstr_default_identify_list[] = {
mbfl_no_encoding_ascii,
} else {
/* auto detect */
from_encoding = mbfl_no_encoding_invalid;
- identd = mbfl_encoding_detector_new(elist, elistsz TSRMLS_CC);
+ identd = mbfl_encoding_detector_new((mbfl_no_encoding *)elist, elistsz TSRMLS_CC);
if (identd != NULL) {
n = 0;
while (n < num) {
string.no_encoding = from_encoding;
} else if (size > 1) {
/* auto detect */
- from_encoding = mbfl_identify_encoding_no(&string, list, size TSRMLS_CC);
+ from_encoding = mbfl_identify_encoding_no(&string, (mbfl_no_encoding *)list, size TSRMLS_CC);
if (from_encoding != mbfl_no_encoding_invalid) {
string.no_encoding = from_encoding;
} else {
}
if (size > 0 && list != NULL) {
- elist = list;
+ elist = (mbfl_no_encoding *)list;
} else {
- elist = MBSTRG(current_detect_order_list);
+ elist = (mbfl_no_encoding *)MBSTRG(current_detect_order_list);
size = MBSTRG(current_detect_order_list_size);
}
stack = (pval ***)emalloc(stack_max*sizeof(pval **));
if (stack != NULL) {
stack_level = 0;
- identd = mbfl_encoding_detector_new(elist, elistsz TSRMLS_CC);
+ identd = mbfl_encoding_detector_new((mbfl_no_encoding *)elist, elistsz TSRMLS_CC);
if (identd != NULL) {
n = 2;
while (n < argc || stack_level > 0) {
orig_str.no_language = MBSTRG(current_language);
orig_str.val = Z_STRVAL_PP(argv[1]);
orig_str.len = Z_STRLEN_PP(argv[1]);
- orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC);
+ orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, (mbfl_no_encoding *)MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC);
if(orig_str.no_encoding == mbfl_no_encoding_invalid) {
orig_str.no_encoding = MBSTRG(current_internal_encoding);
}
orig_str.no_language = MBSTRG(current_language);
orig_str.val = Z_STRVAL_PP(argv[2]);
orig_str.len = Z_STRLEN_PP(argv[2]);
- orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC);
+ orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, (mbfl_no_encoding *)MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC);
if(orig_str.no_encoding == mbfl_no_encoding_invalid) {
orig_str.no_encoding = MBSTRG(current_internal_encoding);
}