libmbfl/filters/mbfilter_euc_cn.c
libmbfl/filters/mbfilter_euc_jp.c
libmbfl/filters/mbfilter_euc_jp_win.c
+ libmbfl/filters/mbfilter_cp51932.c
libmbfl/filters/mbfilter_euc_kr.c
libmbfl/filters/mbfilter_euc_tw.c
libmbfl/filters/mbfilter_htmlent.c
dnl libmbfl is required
PHP_MBSTRING_SETUP_LIBMBFL
PHP_MBSTRING_EXTENSION
- PHP_INSTALL_HEADERS([ext/mbstring], [mbstring.h php_mbregex.h libmbfl/ libmbfl/mbfl/ oniguruma/])
+ PHP_INSTALL_HEADERS([ext/mbstring], [mbstring.h php_mbregex.h libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_allocators.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_ident.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h oniguruma/oniguruma.h oniguruma/php_onig_compat.h])
fi
# vim600: sts=2 sw=2 et
noinst_LTLIBRARIES=libmbfl_filters.la
INCLUDES=-I../mbfl
libmbfl_filters_la_LDFLAGS=-version-info $(SHLIB_VERSION)
-libmbfl_filters_la_SOURCES=mbfilter_cp936.c mbfilter_hz.c mbfilter_euc_tw.c mbfilter_big5.c mbfilter_euc_jp.c mbfilter_jis.c mbfilter_iso8859_1.c mbfilter_iso8859_2.c mbfilter_cp1252.c mbfilter_cp1251.c mbfilter_ascii.c mbfilter_iso8859_3.c mbfilter_iso8859_4.c mbfilter_iso8859_5.c mbfilter_iso8859_6.c mbfilter_iso8859_7.c mbfilter_iso8859_8.c mbfilter_iso8859_9.c mbfilter_iso8859_10.c mbfilter_iso8859_13.c mbfilter_iso8859_14.c mbfilter_iso8859_15.c mbfilter_iso8859_16.c mbfilter_htmlent.c mbfilter_byte2.c mbfilter_byte4.c mbfilter_uuencode.c mbfilter_base64.c mbfilter_sjis.c mbfilter_7bit.c mbfilter_qprint.c mbfilter_ucs4.c mbfilter_ucs2.c mbfilter_utf32.c mbfilter_utf16.c mbfilter_utf8.c mbfilter_utf7.c mbfilter_utf7imap.c mbfilter_euc_jp_win.c mbfilter_cp932.c mbfilter_euc_cn.c mbfilter_euc_kr.c mbfilter_uhc.c mbfilter_iso2022_kr.c mbfilter_cp866.c mbfilter_koi8r.c mbfilter_armscii8.c html_entities.c cp932_table.h html_entities.h mbfilter_7bit.h mbfilter_ascii.h mbfilter_base64.h mbfilter_big5.h mbfilter_byte2.h mbfilter_byte4.h mbfilter_cp1251.h mbfilter_cp1252.h mbfilter_cp866.h mbfilter_cp932.h mbfilter_cp936.h mbfilter_euc_cn.h mbfilter_euc_jp.h mbfilter_euc_jp_win.h mbfilter_euc_kr.h mbfilter_euc_tw.h mbfilter_htmlent.h mbfilter_hz.h mbfilter_iso2022_kr.h mbfilter_iso8859_1.h mbfilter_iso8859_10.h mbfilter_iso8859_13.h mbfilter_iso8859_14.h mbfilter_iso8859_15.h mbfilter_iso8859_16.h mbfilter_iso8859_2.h mbfilter_iso8859_3.h mbfilter_iso8859_4.h mbfilter_iso8859_5.h mbfilter_iso8859_6.h mbfilter_iso8859_7.h mbfilter_iso8859_8.h mbfilter_iso8859_9.h mbfilter_jis.h mbfilter_koi8r.h mbfilter_armscii8.h mbfilter_qprint.h mbfilter_sjis.h mbfilter_ucs2.h mbfilter_ucs4.h mbfilter_uhc.h mbfilter_utf16.h mbfilter_utf32.h mbfilter_utf7.h mbfilter_utf7imap.h mbfilter_utf8.h mbfilter_uuencode.h unicode_prop.h unicode_table_big5.h unicode_table_cns11643.h unicode_table_cp1251.h unicode_table_cp1252.h unicode_table_cp866.h unicode_table_cp932_ext.h unicode_table_cp936.h unicode_table_iso8859_10.h unicode_table_iso8859_13.h unicode_table_iso8859_14.h unicode_table_iso8859_15.h unicode_table_iso8859_16.h unicode_table_iso8859_2.h unicode_table_iso8859_3.h unicode_table_iso8859_4.h unicode_table_iso8859_5.h unicode_table_iso8859_6.h unicode_table_iso8859_7.h unicode_table_iso8859_8.h unicode_table_iso8859_9.h unicode_table_jis.h unicode_table_koi8r.h unicode_table_armscii8.h unicode_table_uhc.h
+libmbfl_filters_la_SOURCES=mbfilter_cp936.c mbfilter_hz.c mbfilter_euc_tw.c mbfilter_big5.c mbfilter_euc_jp.c mbfilter_jis.c mbfilter_iso8859_1.c mbfilter_iso8859_2.c mbfilter_cp1252.c mbfilter_cp1251.c mbfilter_ascii.c mbfilter_iso8859_3.c mbfilter_iso8859_4.c mbfilter_iso8859_5.c mbfilter_iso8859_6.c mbfilter_iso8859_7.c mbfilter_iso8859_8.c mbfilter_iso8859_9.c mbfilter_iso8859_10.c mbfilter_iso8859_13.c mbfilter_iso8859_14.c mbfilter_iso8859_15.c mbfilter_iso8859_16.c mbfilter_htmlent.c mbfilter_byte2.c mbfilter_byte4.c mbfilter_uuencode.c mbfilter_base64.c mbfilter_sjis.c mbfilter_7bit.c mbfilter_qprint.c mbfilter_ucs4.c mbfilter_ucs2.c mbfilter_utf32.c mbfilter_utf16.c mbfilter_utf8.c mbfilter_utf7.c mbfilter_utf7imap.c mbfilter_euc_jp_win.c mbfilter_cp932.c mbfilter_cp51932.c mbfilter_euc_cn.c mbfilter_euc_kr.c mbfilter_uhc.c mbfilter_iso2022_kr.c mbfilter_cp866.c mbfilter_koi8r.c mbfilter_armscii8.c html_entities.c cp932_table.h html_entities.h mbfilter_7bit.h mbfilter_ascii.h mbfilter_base64.h mbfilter_big5.h mbfilter_byte2.h mbfilter_byte4.h mbfilter_cp1251.h mbfilter_cp1252.h mbfilter_cp866.h mbfilter_cp932.h mbfilter_cp51932.h mbfilter_cp936.h mbfilter_euc_cn.h mbfilter_euc_jp.h mbfilter_euc_jp_win.h mbfilter_euc_kr.h mbfilter_euc_tw.h mbfilter_htmlent.h mbfilter_hz.h mbfilter_iso2022_kr.h mbfilter_iso8859_1.h mbfilter_iso8859_10.h mbfilter_iso8859_13.h mbfilter_iso8859_14.h mbfilter_iso8859_15.h mbfilter_iso8859_16.h mbfilter_iso8859_2.h mbfilter_iso8859_3.h mbfilter_iso8859_4.h mbfilter_iso8859_5.h mbfilter_iso8859_6.h mbfilter_iso8859_7.h mbfilter_iso8859_8.h mbfilter_iso8859_9.h mbfilter_jis.h mbfilter_koi8r.h mbfilter_armscii8.h mbfilter_qprint.h mbfilter_sjis.h mbfilter_ucs2.h mbfilter_ucs4.h mbfilter_uhc.h mbfilter_utf16.h mbfilter_utf32.h mbfilter_utf7.h mbfilter_utf7imap.h mbfilter_utf8.h mbfilter_uuencode.h unicode_prop.h unicode_table_big5.h unicode_table_cns11643.h unicode_table_cp1251.h unicode_table_cp1252.h unicode_table_cp866.h unicode_table_cp932_ext.h unicode_table_cp936.h unicode_table_iso8859_10.h unicode_table_iso8859_13.h unicode_table_iso8859_14.h unicode_table_iso8859_15.h unicode_table_iso8859_16.h unicode_table_iso8859_2.h unicode_table_iso8859_3.h unicode_table_iso8859_4.h unicode_table_iso8859_5.h unicode_table_iso8859_6.h unicode_table_iso8859_7.h unicode_table_iso8859_8.h unicode_table_iso8859_9.h unicode_table_jis.h unicode_table_koi8r.h unicode_table_armscii8.h unicode_table_uhc.h
mbfilter_iso8859_2.c: unicode_table_iso8859_2.h
};
-static const char *mbfl_encoding_eucjp_win_aliases[] = {"eucJP-open", NULL};
+static const char *mbfl_encoding_eucjp_win_aliases[] = {"eucJP-open",
+ "eucJP-ms", NULL};
const struct mbfl_identify_vtbl vtbl_identify_eucjpwin = {
mbfl_no_encoding_eucjp_win,
MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE
};
+const mbfl_encoding mbfl_encoding_2022jpms = {
+ mbfl_no_encoding_2022jpms,
+ "ISO-2022-JP-MS",
+ "ISO-2022-JP-MS",
+ NULL,
+ NULL,
+ MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE
+};
+
const struct mbfl_identify_vtbl vtbl_identify_jis = {
mbfl_no_encoding_jis,
mbfl_filt_ident_common_ctor,
mbfl_filt_ident_2022jp
};
+const struct mbfl_identify_vtbl vtbl_identify_2022jpms = {
+ mbfl_no_encoding_2022jpms,
+ mbfl_filt_ident_common_ctor,
+ mbfl_filt_ident_common_dtor,
+ mbfl_filt_ident_2022jp
+};
+
const struct mbfl_convert_vtbl vtbl_jis_wchar = {
mbfl_no_encoding_jis,
mbfl_no_encoding_wchar,
mbfl_filt_conv_any_jis_flush
};
+const struct mbfl_convert_vtbl vtbl_2022jpms_wchar = {
+ mbfl_no_encoding_2022jpms,
+ mbfl_no_encoding_wchar,
+ mbfl_filt_conv_common_ctor,
+ mbfl_filt_conv_common_dtor,
+ mbfl_filt_conv_jis_wchar,
+ mbfl_filt_conv_common_flush
+};
+
+const struct mbfl_convert_vtbl vtbl_wchar_2022jpms = {
+ mbfl_no_encoding_wchar,
+ mbfl_no_encoding_2022jpms,
+ mbfl_filt_conv_common_ctor,
+ mbfl_filt_conv_common_dtor,
+ mbfl_filt_conv_wchar_jis,
+ mbfl_filt_conv_any_jis_flush
+};
+
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)
/*
filter->status += 2;
} else if (c == 0x0e) { /* "kana in" */
filter->status = 0x20;
+ CK((*filter->output_function)(c, filter->data));
} else if (c == 0x0f) { /* "kana out" */
filter->status = 0;
- } else if (filter->status == 0x10 && c == 0x5c) { /* YEN SIGN */
- CK((*filter->output_function)(0xa5, filter->data));
- } else if (filter->status == 0x10 && c == 0x7e) { /* OVER LINE */
- CK((*filter->output_function)(0x203e, filter->data));
+ CK((*filter->output_function)(c, filter->data));
} else if (filter->status == 0x20 && c > 0x20 && c < 0x60) { /* kana */
CK((*filter->output_function)(0xff40 + c, filter->data));
} else if ((filter->status == 0x80 || filter->status == 0x90) && c > 0x20 && c < 0x7f) { /* kanji first char */
s = (c1 - 0x21)*94 + c - 0x21;
if (filter->status == 0x80) {
if (s >= 0 && s < jisx0208_ucs_table_size) {
+ if ((filter->from)->no_encoding !=
+ mbfl_no_encoding_2022jpms) {
+ w = jisx0208_ucs_table[s];
+ }
+ else {
+ if ((c1 - 0x21) == 12) {
+ w = cp932ext1_ucs_table[s-12*94];
+ }
+ else {
+ if (c1 >= 0x79 && c1 <= 0x7c) {
+ w = cp932ext2_ucs_table[s-(0x79-0x21)*94];
+ }
+ else {
w = jisx0208_ucs_table[s];
+ }
+ }
+ }
} else {
+ if ((filter->from)->no_encoding !=
+ mbfl_no_encoding_2022jpms) {
+ w = 0;
+ } else {
+ if (c1 >= 0x79 && c1 <= 0x7c) {
+ w = cp932ext2_ucs_table[s-(0x79-0x21)*94];
+ } else {
w = 0;
+ }
+ }
}
if (w <= 0) {
w = (c1 << 8) | c;
int
mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter)
{
- int c1, s;
+ int c1, c2, s;
s = 0;
if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
} else if (c >= ucs_r_jis_table_min && c < ucs_r_jis_table_max) {
s = ucs_r_jis_table[c - ucs_r_jis_table_min];
}
+ if (s > 0x8080 && s < 0x10000 &&
+ ((filter->to)->no_encoding == mbfl_no_encoding_2022jpms)) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
if (s <= 0) {
c1 = c & ~MBFL_WCSPLANE_MASK;
if (c1 == MBFL_WCSPLANE_JIS0208) {
}
if (c == 0) {
s = 0;
- } else if (s <= 0) {
+ } else if (s <= 0 && ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms)) {
s = -1;
+ c1 = 0;
+ c2 = cp932ext1_ucs_table_max - cp932ext1_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext1 (13ku) */
+ if (c == cp932ext1_ucs_table[c1]) {
+ s = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ if (s < 0 && ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms)) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
}
}
if (s >= 0) {
int
mbfl_filt_conv_wchar_2022jp(int c, mbfl_convert_filter *filter)
{
- int s;
+ int c1, c2, s;
s = 0;
if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
s = 0;
} else if (s <= 0) {
s = -1;
+ if ( (filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms) {
+ c1 = 0;
+ c2 = cp932ext1_ucs_table_max - cp932ext1_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext1 (13ku) */
+ if (c == cp932ext1_ucs_table[c1]) {
+ s = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ if ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
+ }
}
- } else if ((s >= 0x80 && s < 0x2121) || (s > 0x8080)) {
+ } else if (((s >= 0x80 && s < 0x2121) &&
+ (filter->to)->no_encoding != mbfl_no_encoding_2022jpms) ||
+ (s > 0x8080)) {
s = -1;
+ if ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
}
if (s >= 0) {
if (s < 0x80) { /* ASCII */
}
filter->status = 0;
CK((*filter->output_function)(s, filter->data));
+ } else if (s < 0x100 && ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms)) { /* kana */
+ if ((filter->status & 0xff00) != 0x100) {
+ CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
+ CK((*filter->output_function)(0x28, filter->data)); /* '(' */
+ CK((*filter->output_function)(0x49, filter->data)); /* 'I' */
+ }
+ filter->status = 0x100;
+ CK((*filter->output_function)(s & 0x7f, filter->data));
} else if (s < 0x10000) { /* X 0208 */
if ((filter->status & 0xff00) != 0x200) {
CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
extern const mbfl_encoding mbfl_encoding_jis;
extern const mbfl_encoding mbfl_encoding_2022jp;
+extern const mbfl_encoding mbfl_encoding_2022jpms;
extern const struct mbfl_identify_vtbl vtbl_identify_2022jp;
+extern const struct mbfl_identify_vtbl vtbl_identify_2022jpms;
extern const struct mbfl_identify_vtbl vtbl_identify_jis;
extern const struct mbfl_convert_vtbl vtbl_jis_wchar;
extern const struct mbfl_convert_vtbl vtbl_wchar_jis;
extern const struct mbfl_convert_vtbl vtbl_2022jp_wchar;
extern const struct mbfl_convert_vtbl vtbl_wchar_2022jp;
+extern const struct mbfl_convert_vtbl vtbl_2022jpms_wchar;
+extern const struct mbfl_convert_vtbl vtbl_wchar_2022jpms;
int mbfl_filt_conv_jis_wchar(int c, mbfl_convert_filter *filter);
int mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter);
0xFF1F,0xFF01,0x309B,0x309C,0x00B4,0xFF40,0x00A8,0xFF3E,
0xFFE3,0xFF3F,0x30FD,0x30FE,0x309D,0x309E,0x3003,0x4EDD,
0x3005,0x3006,0x3007,0x30FC,0x2015,0x2010,0xFF0F,0xFF3C,
- 0x301C,0x2016,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C,
+ 0xFF5E,0x2225,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C,
0x201D,0xFF08,0xFF09,0x3014,0x3015,0xFF3B,0xFF3D,0xFF5B,
0xFF5D,0x3008,0x3009,0x300A,0x300B,0x300C,0x300D,0x300E,
- 0x300F,0x3010,0x3011,0xFF0B,0x2212,0x00B1,0x00D7,0x00F7,
+ 0x300F,0x3010,0x3011,0xFF0B,0xFF0D,0x00B1,0x00D7,0x00F7,
0xFF1D,0x2260,0xFF1C,0xFF1E,0x2266,0x2267,0x221E,0x2234,
0x2642,0x2640,0x00B0,0x2032,0x2033,0x2103,0xFFE5,0xFF04,
- 0x00A2,0x00A3,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7,
+ 0xFFE0,0xFFE1,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7,
0x2606,0x2605,0x25CB,0x25CF,0x25CE,0x25C7,
/* ku 2 */
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x2208,0x220B,0x2286,0x2287,0x2282,0x2283,0x222A,
0x2229,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x2227,0x2228,0x00AC,0x21D2,0x21D4,0x2200,0x2203,
+ 0x0000,0x2227,0x2228,0xFFE2,0x21D2,0x21D4,0x2200,0x2203,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x2220,0x22A5,0x2312,0x2202,0x2207,
0x2261,0x2252,0x226A,0x226B,0x221A,0x223D,0x221D,0x2235,
/* ku 2 */
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x02D8,0x02C7,
- 0x00B8,0x02D9,0x02DD,0x00AF,0x02DB,0x02DA,0x007E,0x0384,
+ 0x00B8,0x02D9,0x02DD,0x00AF,0x02DB,0x02DA,0xFF5E,0x0384,
0x0385,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x00A1,0x00A6,0x00BF,0x0000,0x0000,0x0000,0x0000,
+ 0x0000,0x00A1,0xFFE4,0x00BF,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 2100h */
0x0000,0x0000,0x0000,0x216E,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xA2F1,0x0000,
+ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2d62,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0xA2EF,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x2272,0x0000,0x0000,0x0000,0x0000,
n--;
}
- /* fallback judge */
if (encoding == mbfl_no_encoding_invalid) {
n = identd->filter_list_size - 1;
while (n >= 0) {
}
}
-
/* cleanup */
/* dtors should be called in reverse order */
i = num; while (--i >= 0) {
#include "filters/mbfilter_euc_kr.h"
#include "filters/mbfilter_iso2022_kr.h"
#include "filters/mbfilter_sjis.h"
+#include "filters/mbfilter_cp51932.h"
#include "filters/mbfilter_jis.h"
#include "filters/mbfilter_euc_jp.h"
#include "filters/mbfilter_euc_jp_win.h"
&vtbl_wchar_eucjp,
&vtbl_sjis_wchar,
&vtbl_wchar_sjis,
+ &vtbl_cp51932_wchar,
+ &vtbl_wchar_cp51932,
&vtbl_jis_wchar,
&vtbl_wchar_jis,
&vtbl_2022jp_wchar,
&vtbl_wchar_2022jp,
+ &vtbl_2022jpms_wchar,
+ &vtbl_wchar_2022jpms,
&vtbl_eucjpwin_wchar,
&vtbl_wchar_eucjpwin,
&vtbl_sjiswin_wchar,
#include "filters/mbfilter_euc_kr.h"
#include "filters/mbfilter_iso2022_kr.h"
#include "filters/mbfilter_sjis.h"
+#include "filters/mbfilter_cp51932.h"
#include "filters/mbfilter_jis.h"
#include "filters/mbfilter_euc_jp.h"
#include "filters/mbfilter_euc_jp_win.h"
&mbfl_encoding_sjis,
&mbfl_encoding_eucjp_win,
&mbfl_encoding_sjis_win,
+ &mbfl_encoding_cp51932,
&mbfl_encoding_jis,
&mbfl_encoding_2022jp,
+ &mbfl_encoding_2022jpms,
&mbfl_encoding_cp1252,
&mbfl_encoding_8859_1,
&mbfl_encoding_8859_2,
mbfl_no_encoding_eucjp_win,
mbfl_no_encoding_sjis_win,
mbfl_no_encoding_sjis_mac,
+ mbfl_no_encoding_cp51932,
mbfl_no_encoding_jis,
mbfl_no_encoding_2022jp,
+ mbfl_no_encoding_2022jpms,
mbfl_no_encoding_cp1252,
mbfl_no_encoding_8859_1,
mbfl_no_encoding_8859_2,
&vtbl_identify_sjiswin,
&vtbl_identify_jis,
&vtbl_identify_2022jp,
+ &vtbl_identify_2022jpms,
&vtbl_identify_euccn,
&vtbl_identify_cp936,
&vtbl_identify_hz,
info.num_from_encodings = MBSTRG(http_input_list_size);
info.from_language = MBSTRG(language);
+ MBSTRG(illegalchars) = 0;
+
detected = _php_mb_encoding_handler_ex(&info, array_ptr, res TSRMLS_CC);
MBSTRG(http_input_identify) = detected;
out:
if (convd != NULL) {
+ MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
if (val_list != NULL) {
#include "ext/standard/url.h"
#include "main/php_output.h"
#include "ext/standard/info.h"
+
#include "libmbfl/mbfl/mbfl_allocators.h"
#include "php_variables.h"
MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding);
MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode);
MBSTRG(current_filter_illegal_substchar) = MBSTRG(filter_illegal_substchar);
- MBSTRG(illegalchars) = 0;
+
+ if (!MBSTRG(encoding_translation)) {
+ MBSTRG(illegalchars) = 0;
+ }
n = 0;
if (MBSTRG(detect_order_list)) {
zend_hash_find(EG(function_table), p->ovld_func, strlen(p->ovld_func)+1 , (void **)&func);
if (zend_hash_find(EG(function_table), p->orig_func, strlen(p->orig_func)+1, (void **)&orig) != SUCCESS) {
- php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't find function %s", p->orig_func);
+ php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't find function %s.", p->orig_func);
return FAILURE;
} else {
zend_hash_add(EG(function_table), p->save_func, strlen(p->save_func)+1, orig, sizeof(zend_function), NULL);
if (zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, func, sizeof(zend_function),
NULL) == FAILURE) {
- php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s", p->orig_func);
+ php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s.", p->orig_func);
return FAILURE;
}
}
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_PP(arg1);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character.");
RETVAL_FALSE;
}
}
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_PP(arg1);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character.");
RETVAL_FALSE;
}
break;
}
if (offset < 0 || (unsigned long)offset > haystack.len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is out of range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string.");
RETURN_FALSE;
}
if (needle.len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
RETURN_FALSE;
}
case 1:
break;
case 2:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Needle has non-positive length");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Needle has not positive length.");
break;
case 4:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding or conversion error");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding or conversion error.");
break;
case 8:
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Argument is empty");
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Argument is empty.");
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error in mb_strpos");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error in mb_strpos.");
break;
}
RETVAL_FALSE;
PHP_FUNCTION(mb_strrpos)
{
int n;
- long offset = 0;
mbfl_string haystack, needle;
char *enc_name = NULL;
int enc_name_len;
+ zval **zoffset;
+ long offset = 0, str_flg;
+ char *enc_name2 = NULL;
+ int enc_name_len2;
mbfl_string_init(&haystack);
mbfl_string_init(&needle);
needle.no_language = MBSTRG(current_language);
needle.no_encoding = MBSTRG(current_internal_encoding);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ls", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name, &enc_name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|Zs", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &zoffset, &enc_name, &enc_name_len) == FAILURE) {
RETURN_FALSE;
}
+ if(ZEND_NUM_ARGS() >= 3) {
+ if (Z_TYPE_PP(zoffset) == IS_STRING) {
+ enc_name2 = Z_STRVAL_PP(zoffset);
+ enc_name_len2 = Z_STRLEN_PP(zoffset);
+ str_flg = 1;
+
+ if (enc_name2 != NULL) {
+ switch (*enc_name2) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ' ':
+ case '-':
+ case '.':
+ break;
+ default :
+ str_flg = 0;
+ break;
+ }
+ }
+
+ if(str_flg) {
+ convert_to_long_ex(zoffset);
+ offset = Z_LVAL_PP(zoffset);
+ } else {
+ enc_name = enc_name2;
+ enc_name_len = enc_name_len2;
+ }
+ } else {
+ convert_to_long_ex(zoffset);
+ offset = Z_LVAL_PP(zoffset);
+ }
+ }
+
if (enc_name != NULL) {
haystack.no_encoding = needle.no_encoding = mbfl_name2no_encoding(enc_name);
if (haystack.no_encoding == mbfl_no_encoding_invalid) {
}
if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
RETURN_FALSE;
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, offset, 1);
RETURN_FALSE;
}
+ if(offset > old_haystack_len){
+ RETURN_FALSE;
+ }
+
n = php_mb_stripos(1, old_haystack, old_haystack_len, old_needle, old_needle_len, offset, from_encoding TSRMLS_CC);
if (n >= 0) {
}
}
- if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
- RETURN_FALSE;
- }
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty delimiter.");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, 0, 0);
}
}
+ if (haystack.len <= 0) {
+ RETURN_FALSE;
+ }
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, 0, 1);
RETURN_FALSE;
}
+ if(!needle.len){
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty delimiter.");
+ RETURN_FALSE;
+ }
+
haystack.no_encoding = needle.no_encoding = mbfl_name2no_encoding(from_encoding);
if (haystack.no_encoding == mbfl_no_encoding_invalid) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding \"%s\"", from_encoding);
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty substring.");
RETURN_FALSE;
}
if (((unsigned) from + (unsigned) len) > Z_STRLEN_PP(arg1)) {
len = Z_STRLEN_PP(arg1) - from;
}
-
+
ret = mbfl_strcut(&string, &result, from, len);
if (ret != NULL) {
RETVAL_STRINGL(ret->val, ret->len, 0); /* the string is already strdup()'ed */
mbfl_string string;
const char *ret;
enum mbfl_no_encoding *elist;
- int size, *list, strict;
+ int size, *list, strict = 0;
if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &arg_str) == FAILURE) {
if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_body_encoding)) != NULL) {
RETVAL_STRING(name, 1);
}
- } else if (!strcasecmp("illegal_chars", typ)) {
- RETVAL_LONG(MBSTRG(illegalchars));
+ } else if (!strcasecmp("illegal_chars", typ)) {
+ RETVAL_LONG(MBSTRG(illegalchars));
} else if (!strcasecmp("encoding_translation", typ)) {
if (MBSTRG(encoding_translation)) {
RETVAL_STRING("On", 1);
if (ret != NULL) {
MBSTRG(illegalchars) += illegalchars;
- efree(ret->val);
- RETURN_BOOL(illegalchars == 0);
+ if (illegalchars == 0 && strncmp(string.val, ret->val, string.len) == 0) {
+ efree(ret->val);
+ RETURN_TRUE;
+ } else {
+ efree(ret->val);
+ RETURN_FALSE;
+ }
} else {
RETURN_FALSE;
}
}
if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
break;
}
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty needle");
break;
}
}
if (offset < 0 || (unsigned long)offset > haystack.len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is out of range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string.");
break;
}