MFH: added iso2022jp-mobile and emoji unsuppoted in unicode 6.0.

This commit is contained in:
Rui Hirokawa 2011-08-24 15:29:17 +00:00
parent d4a50542ea
commit 942dd584d3
13 changed files with 1365 additions and 747 deletions

View File

@ -246,6 +246,7 @@ AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
libmbfl/filters/mbfilter_hz.c
libmbfl/filters/mbfilter_iso2022_jp_ms.c
libmbfl/filters/mbfilter_iso2022jp_2004.c
libmbfl/filters/mbfilter_iso2022jp_mobile.c
libmbfl/filters/mbfilter_iso2022_kr.c
libmbfl/filters/mbfilter_iso8859_1.c
libmbfl/filters/mbfilter_iso8859_10.c

View File

@ -35,8 +35,9 @@ if (PHP_MBSTRING != "no") {
mbfilter_utf7.c mbfilter_utf7imap.c mbfilter_utf8.c mbfilter_utf8_mobile.c \
mbfilter_koi8u.c mbfilter_cp1254.c mbfilter_euc_jp_2004.c \
mbfilter_uuencode.c mbfilter_armscii8.c mbfilter_cp850.c \
mbfilter_cp5022x.c mbfilter_sjis_open.c mbfilter_sjis_mobile.c mbfilter_sjis_mac.c \
mbfilter_iso2022jp_2004.c \
mbfilter_cp5022x.c mbfilter_sjis_open.c mbfilter_sjis_mobile.c \
mbfilter_sjis_mac.c \
mbfilter_iso2022jp_2004.c mbfilter_iso2022jp_mobile.c \
mbfilter_tl_jisx0201_jisx0208.c", "mbstring");
ADD_SOURCES("ext/mbstring/libmbfl/mbfl", "mbfilter.c mbfilter_8bit.c \

View File

@ -56,6 +56,7 @@ libmbfl_filters_la_SOURCES=mbfilter_cp936.c \
mbfilter_uhc.c \
mbfilter_iso2022_jp_ms.c \
mbfilter_iso2022jp_2004.c \
mbfilter_iso2022jp_mobile.c \
mbfilter_gb18030.c \
mbfilter_iso2022_kr.c \
mbfilter_cp866.c \
@ -91,6 +92,7 @@ libmbfl_filters_la_SOURCES=mbfilter_cp936.c \
mbfilter_hz.h \
mbfilter_iso2022_jp_ms.h \
mbfilter_iso2022jp_2004.h \
mbfilter_iso2022jp_mobile.h \
mbfilter_iso2022_kr.h \
mbfilter_iso8859_1.h \
mbfilter_iso8859_10.h \

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
#include "unicode_table_jis.h"
#include "cp932_table.h"
static int mbfl_filt_ident_2022jpms(int c, mbfl_identify_filter *filter);
int mbfl_filt_ident_2022jpms(int c, mbfl_identify_filter *filter);
static const char *mbfl_encoding_2022jpms_aliases[] = {"ISO2022JPMS", NULL};
@ -433,7 +433,7 @@ mbfl_filt_conv_any_2022jpms_flush(mbfl_convert_filter *filter)
return 0;
}
static int mbfl_filt_ident_2022jpms(int c, mbfl_identify_filter *filter)
int mbfl_filt_ident_2022jpms(int c, mbfl_identify_filter *filter)
{
retry:
switch (filter->status & 0xf) {

View File

@ -0,0 +1,431 @@
/*
* "streamable kanji code filter and converter"
* Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
*
* LICENSE NOTICES
*
* This file is part of "streamable kanji code filter and converter",
* which is distributed under the terms of GNU Lesser General Public
* License (version 2) as published by the Free Software Foundation.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with "streamable kanji code filter and converter";
* if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*
* The author of this file:
*
*/
/*
* The source code included in this files was separated from mbfilter_iso2022_jp_ms.c
* by Rui Hirokawa <hirokawa@php.net> on 25 July 2011.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mbfilter.h"
#include "mbfilter_iso2022jp_mobile.h"
#include "mbfilter_sjis_mobile.h"
#include "unicode_table_cp932_ext.h"
#include "unicode_table_jis.h"
#include "cp932_table.h"
extern int mbfl_filt_conv_any_jis_flush(mbfl_convert_filter *filter);
extern int mbfl_filt_ident_2022jpms(int c, mbfl_identify_filter *filter);
const mbfl_encoding mbfl_encoding_2022jp_kddi = {
mbfl_no_encoding_2022jp_kddi,
"ISO-2022-JP-MOBILE#KDDI",
"ISO-2022-JP",
NULL,
NULL,
MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE | MBFL_ENCTYPE_GL_UNSAFE
};
const struct mbfl_identify_vtbl vtbl_identify_2022jp_kddi = {
mbfl_no_encoding_2022jp_kddi,
mbfl_filt_ident_common_ctor,
mbfl_filt_ident_common_dtor,
mbfl_filt_ident_2022jpms
};
const struct mbfl_convert_vtbl vtbl_2022jp_kddi_wchar = {
mbfl_no_encoding_2022jp_kddi,
mbfl_no_encoding_wchar,
mbfl_filt_conv_common_ctor,
mbfl_filt_conv_common_dtor,
mbfl_filt_conv_2022jp_mobile_wchar,
mbfl_filt_conv_common_flush
};
const struct mbfl_convert_vtbl vtbl_wchar_2022jp_kddi = {
mbfl_no_encoding_wchar,
mbfl_no_encoding_2022jp_kddi,
mbfl_filt_conv_common_ctor,
mbfl_filt_conv_common_dtor,
mbfl_filt_conv_wchar_2022jp_mobile,
mbfl_filt_conv_any_jis_flush
};
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)
#define sjistoidx(c1, c2) \
(((c1) > 0x9f) \
? (((c1) - 0xc1) * 188 + (c2) - (((c2) > 0x7e) ? 0x41 : 0x40)) \
: (((c1) - 0x81) * 188 + (c2) - (((c2) > 0x7e) ? 0x41 : 0x40)))
#define idxtojis1(c) (((c) / 94) + 0x21)
#define idxtojis2(c) (((c) % 94) + 0x21)
#define SJIS_ENCODE(c1,c2,s1,s2) \
do { \
s1 = c1; \
s1--; \
s1 >>= 1; \
if ((c1) < 0x5f) { \
s1 += 0x71; \
} else { \
s1 += 0xb1; \
} \
s2 = c2; \
if ((c1) & 1) { \
if ((c2) < 0x60) { \
s2--; \
} \
s2 += 0x20; \
} else { \
s2 += 0x7e; \
} \
} while (0)
#define SJIS_DECODE(c1,c2,s1,s2) \
do { \
s1 = c1; \
if (s1 < 0xa0) { \
s1 -= 0x81; \
} else { \
s1 -= 0xc1; \
} \
s1 <<= 1; \
s1 += 0x21; \
s2 = c2; \
if (s2 < 0x9f) { \
if (s2 < 0x7f) { \
s2++; \
} \
s2 -= 0x20; \
} else { \
s1++; \
s2 -= 0x7e; \
} \
} while (0)
#define CODE2JIS(c1,c2,s1,s2) \
c1 = (s1)/94+0x21; \
c2 = (s1)-94*((c1)-0x21)+0x21; \
s1 = ((c1) << 8) | (c2); \
s2 = 1
/*
* ISO-2022-JP-Mobile => wchar
*/
int
mbfl_filt_conv_2022jp_mobile_wchar(int c, mbfl_convert_filter *filter)
{
int c1, c2, s, w, s1, s2, snd;
retry:
switch (filter->status & 0xf) {
/* case 0x00: ASCII */
/* case 0x10: X 0201 latin */
/* case 0x20: X 0201 kana */
/* case 0x80: X 0208 */
case 0:
if (c == 0x1b) {
filter->status += 2;
} else if (filter->status == 0x20 && c > 0x20 && c < 0x60) { /* kana */
CK((*filter->output_function)(0xff40 + c, filter->data));
} else if (filter->status == 0x80 && c > 0x20 && c < 0x80) { /* kanji first char */
filter->cache = c;
filter->status += 1;
} else if (c >= 0 && c < 0x80) { /* latin, CTLs */
CK((*filter->output_function)(c, filter->data));
} else if (c > 0xa0 && c < 0xe0) { /* GR kana */
CK((*filter->output_function)(0xfec0 + c, filter->data));
} else {
w = c & MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
break;
/* case 0x81: X 0208 second char */
case 1:
w = 0;
filter->status &= ~0xf;
c1 = filter->cache;
if (c > 0x20 && c < 0x7f) {
s = (c1 - 0x21)*94 + c - 0x21;
if (s <= 137) {
if (s == 31) {
w = 0xff3c; /* FULLWIDTH REVERSE SOLIDUS */
} else if (s == 32) {
w = 0xff5e; /* FULLWIDTH TILDE */
} else if (s == 33) {
w = 0x2225; /* PARALLEL TO */
} else if (s == 60) {
w = 0xff0d; /* FULLWIDTH HYPHEN-MINUS */
} else if (s == 80) {
w = 0xffe0; /* FULLWIDTH CENT SIGN */
} else if (s == 81) {
w = 0xffe1; /* FULLWIDTH POUND SIGN */
} else if (s == 137) {
w = 0xffe2; /* FULLWIDTH NOT SIGN */
}
}
if (w == 0) {
if (s >= cp932ext1_ucs_table_min && s < cp932ext1_ucs_table_max) { /* vendor ext1 (13ku) */
w = cp932ext1_ucs_table[s - cp932ext1_ucs_table_min];
} else if (s >= 0 && s < jisx0208_ucs_table_size) {
w = jisx0208_ucs_table[s];
} else {
w = 0;
}
}
if (s >= (84*94) && s < 91*94) {
s += 22*94;
if (filter->from->no_encoding == mbfl_no_encoding_2022jp_kddi) {
w = mbfilter_sjis_emoji_kddi2unicode(s, &snd);
}
if (w > 0 && snd > 0) {
CK((*filter->output_function)(snd, filter->data));
}
}
if (w <= 0) {
w = (c1 << 8) | c;
w &= MBFL_WCSPLANE_MASK;
w |= MBFL_WCSPLANE_JIS0208;
}
CK((*filter->output_function)(w, filter->data));
} else if (c == 0x1b) {
filter->status += 2;
} else if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
CK((*filter->output_function)(c, filter->data));
} else {
w = (c1 << 8) | c;
w &= MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
break;
/* ESC */
/* case 0x02: */
/* case 0x12: */
/* case 0x22: */
/* case 0x82: */
case 2:
if (c == 0x24) { /* '$' */
filter->status++;
} else if (c == 0x28) { /* '(' */
filter->status += 3;
} else {
filter->status &= ~0xf;
CK((*filter->output_function)(0x1b, filter->data));
goto retry;
}
break;
/* ESC $ */
/* case 0x03: */
/* case 0x13: */
/* case 0x23: */
/* case 0x83: */
case 3:
if (c == 0x40 || c == 0x42) { /* '@' or 'B' */
filter->status = 0x80;
} else if (c == 0x28) { /* '(' */
filter->status++;
} else {
filter->status &= ~0xf;
CK((*filter->output_function)(0x1b, filter->data));
CK((*filter->output_function)(0x24, filter->data));
goto retry;
}
break;
/* ESC $ ( */
/* case 0x04: */
/* case 0x14: */
/* case 0x24: */
/* case 0x84: */
case 4:
if (c == 0x40 || c == 0x42) { /* '@' or 'B' */
filter->status = 0x80;
} else {
filter->status &= ~0xf;
CK((*filter->output_function)(0x1b, filter->data));
CK((*filter->output_function)(0x24, filter->data));
CK((*filter->output_function)(0x28, filter->data));
goto retry;
}
break;
/* ESC ( */
/* case 0x05: */
/* case 0x15: */
/* case 0x25: */
/* case 0x85: */
case 5:
if (c == 0x42) { /* 'B' */
filter->status = 0;
} else if (c == 0x4a) { /* 'J' */
filter->status = 0;
} else if (c == 0x49) { /* 'I' */
filter->status = 0x20;
} else {
filter->status &= ~0xf;
CK((*filter->output_function)(0x1b, filter->data));
CK((*filter->output_function)(0x28, filter->data));
goto retry;
}
break;
default:
filter->status = 0;
break;
}
return c;
}
/*
* wchar => ISO-2022-JP-Mobile
*/
int
mbfl_filt_conv_wchar_2022jp_mobile(int c, mbfl_convert_filter *filter)
{
int c1, c2, s1, s2;
s1 = 0;
s2 = 0;
if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
s1 = ucs_a1_jis_table[c - ucs_a1_jis_table_min];
} else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) {
s1 = ucs_a2_jis_table[c - ucs_a2_jis_table_min];
} else if (c >= ucs_i_jis_table_min && c < ucs_i_jis_table_max) {
s1 = ucs_i_jis_table[c - ucs_i_jis_table_min];
} else if (c >= ucs_r_jis_table_min && c < ucs_r_jis_table_max) {
s1 = ucs_r_jis_table[c - ucs_r_jis_table_min];
} else if (c >= 0xe000 && c < (0xe000 + 20*94)) { /* user (95ku - 114ku) */
s1 = c - 0xe000;
c1 = s1/94 + 0x7f;
c2 = s1%94 + 0x21;
s1 = (c1 << 8) | c2;
}
if (s1 <= 0) {
c1 = c & ~MBFL_WCSPLANE_MASK;
if (c1 == MBFL_WCSPLANE_WINCP932) {
s1 = c & MBFL_WCSPLANE_MASK;
s2 = 1;
} else if (c1 == MBFL_WCSPLANE_JIS0208) {
s1 = c & MBFL_WCSPLANE_MASK;
} else if (c1 == MBFL_WCSPLANE_JIS0212) {
s1 = c & MBFL_WCSPLANE_MASK;
s1 |= 0x8080;
} else if (c == 0xa5) { /* YEN SIGN */
s1 = 0x216f; /* FULLWIDTH YEN SIGN */
} else if (c == 0x203e) { /* OVER LINE */
s1 = 0x2131; /* FULLWIDTH MACRON */
} else if (c == 0xff3c) { /* FULLWIDTH REVERSE SOLIDUS */
s1 = 0x2140;
} else if (c == 0xff5e) { /* FULLWIDTH TILDE */
s1 = 0x2141;
} else if (c == 0x2225) { /* PARALLEL TO */
s1 = 0x2142;
} else if (c == 0xff0d) { /* FULLWIDTH HYPHEN-MINUS */
s1 = 0x215d;
} else if (c == 0xffe0) { /* FULLWIDTH CENT SIGN */
s1 = 0x2171;
} else if (c == 0xffe1) { /* FULLWIDTH POUND SIGN */
s1 = 0x2172;
} else if (c == 0xffe2) { /* FULLWIDTH NOT SIGN */
s1 = 0x224c;
}
}
if ((s1 <= 0) || (s1 >= 0xa1a1 && s2 == 0)) { /* not found or X 0212 */
s1 = -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]) {
s1 = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21);
break;
}
c1++;
}
if (c == 0) {
s1 = 0;
} else if (s1 <= 0) {
s1 = -1;
}
}
if (filter->to->no_encoding == mbfl_no_encoding_2022jp_kddi &&
mbfilter_unicode2sjis_emoji_kddi(c, &s1, filter) > 0) {
CODE2JIS(c1,c2,s1,s2);
s1 -= 0x1600;
}
if (filter->status == 1 && filter->cache > 0) {
return c;
}
if (s1 >= 0) {
if (s1 < 0x80) { /* latin */
if ((filter->status & 0xff00) != 0) {
CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
CK((*filter->output_function)(0x28, filter->data)); /* '(' */
CK((*filter->output_function)(0x42, filter->data)); /* 'B' */
}
CK((*filter->output_function)(s1, filter->data));
filter->status = 0;
} else if (s1 > 0xa0 && s1 < 0xe0) { /* 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)(s1 & 0x7f, filter->data));
} else if (s1 < 0x7e7f) { /* X 0208 */
if ((filter->status & 0xff00) != 0x200) {
CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
CK((*filter->output_function)(0x24, filter->data)); /* '$' */
CK((*filter->output_function)(0x42, filter->data)); /* 'B' */
}
filter->status = 0x200;
CK((*filter->output_function)((s1 >> 8) & 0xff, filter->data));
CK((*filter->output_function)(s1 & 0x7f, filter->data));
}
} else {
if (filter->illegal_mode != MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
CK(mbfl_filt_conv_illegal_output(c, filter));
}
}
return c;
}

View File

@ -0,0 +1,43 @@
/*
* "streamable kanji code filter and converter"
* Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
*
* LICENSE NOTICES
*
* This file is part of "streamable kanji code filter and converter",
* which is distributed under the terms of GNU Lesser General Public
* License (version 2) as published by the Free Software Foundation.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with "streamable kanji code filter and converter";
* if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*
* The author of this file:
*
*/
/*
* The source code included in this files was separated from mbfilter_iso2022_jp_ms.h
* by Rui Hirokawa <hirokawa@php.net> on 25 July 2011.
*
*/
#ifndef MBFL_MBFILTER_ISO2022_JP_MOBILE_H
#define MBFL_MBFILTER_ISO2022_JP_MOBILE_H
#include "mbfilter.h"
extern const mbfl_encoding mbfl_encoding_2022jp_kddi;
extern const struct mbfl_identify_vtbl vtbl_identify_2022jp_kddi;
extern const struct mbfl_convert_vtbl vtbl_2022jp_kddi_wchar;
extern const struct mbfl_convert_vtbl vtbl_wchar_2022jp_kddi;
int mbfl_filt_conv_2022jp_mobile_wchar(int c, mbfl_convert_filter *filter);
int mbfl_filt_conv_wchar_2022jp_mobile(int c, mbfl_convert_filter *filter);
#endif /* MBFL_MBFILTER_ISO2022_JP_MOBILE_H */

View File

@ -40,6 +40,7 @@
#include "emoji2uni.h"
extern int mbfl_bisec_srch2(int w, const unsigned short tbl[], int n);
extern int mbfl_filt_ident_sjis(int c, mbfl_identify_filter *filter);
extern const unsigned char mblen_table_sjis[];
@ -149,14 +150,14 @@ static const char nflags_s[10][2] = {"CN","DE","ES","FR","GB","IT","JP","KR","RU
static const int nflags_code_kddi[10] = {0x2549, 0x2546, 0x24c0, 0x2545, 0x2548, 0x2547, 0x2750, 0x254a, 0x24c1, 0x27f7};
static const int nflags_code_sb[10] = {0x2b0a, 0x2b05, 0x2b08, 0x2b04, 0x2b07, 0x2b06, 0x2b02, 0x2b0b, 0x2b09, 0x2b03};
const int mbfl_docomo2uni_pua[4][3] = {
const unsigned short mbfl_docomo2uni_pua[4][3] = {
{0x28c2, 0x2929, 0xe63e},
{0x2930, 0x2932, 0xe6ac},
{0x2935, 0x293e, 0xe6b1},
{0x2952, 0x29db, 0xe6ce},
};
const int mbfl_kddi2uni_pua[6][3] = {
const unsigned short mbfl_kddi2uni_pua[6][3] = {
{0x26ec, 0x2838, 0xe468},
{0x284c, 0x2863, 0xe5b5},
{0x24b8, 0x24ca, 0xe5cd},
@ -165,7 +166,7 @@ const int mbfl_kddi2uni_pua[6][3] = {
{0x2546, 0x25c0, 0xeb0e},
};
const int mbfl_sb2uni_pua[6][3] = {
const unsigned short mbfl_sb2uni_pua[6][3] = {
{0x27a9, 0x2802, 0xe101},
{0x2808, 0x285a, 0xe201},
{0x2921, 0x297a, 0xe001},
@ -174,7 +175,7 @@ const int mbfl_sb2uni_pua[6][3] = {
{0x2af8, 0x2b2e, 0xe501},
};
const int mbfl_kddi2uni_pua_b[8][3] = {
const unsigned short mbfl_kddi2uni_pua_b[8][3] = {
{0x24b8, 0x24f6, 0xec40},
{0x24f7, 0x2573, 0xec80},
{0x2574, 0x25b2, 0xed40},
@ -239,7 +240,7 @@ const int mbfl_kddi2uni_pua_b[8][3] = {
s2 = 1
int
mbfilter_conv_map_tbl(int c, int *w, const int map[][3], int n)
mbfilter_conv_map_tbl(int c, int *w, const unsigned short map[][3], int n)
{
int i, match = 0;
@ -254,7 +255,7 @@ mbfilter_conv_map_tbl(int c, int *w, const int map[][3], int n)
}
int
mbfilter_conv_r_map_tbl(int c, int *w, const int map[][3], int n)
mbfilter_conv_r_map_tbl(int c, int *w, const unsigned short map[][3], int n)
{
int i, match = 0;
@ -268,21 +269,6 @@ mbfilter_conv_r_map_tbl(int c, int *w, const int map[][3], int n)
return match;
}
int
mbfilter_conv_seq_tbl(int c, int *w, const int *key, const int *val, int n)
{
int i, match = 0;
for (i = 0; i< n; i++) {
if (c == key[i]) {
*w = val[i];
match = 1;
break;
}
}
return match;
}
int
mbfilter_sjis_emoji_docomo2unicode(int s, int *snd)
{
@ -293,14 +279,23 @@ mbfilter_sjis_emoji_docomo2unicode(int s, int *snd)
s != mb_tbl_code2uni_docomo1_min + 0x00a3) {
w = 0x20E3;
*snd = mb_tbl_code2uni_docomo1[s - mb_tbl_code2uni_docomo1_min];
if (*snd > 0xf000) {
*snd += 0x10000;
}
} else {
w = mb_tbl_code2uni_docomo1[s - mb_tbl_code2uni_docomo1_min];
if (w > 0xf000) {
w += 0x10000;
} else if (w > 0xe000) { /* unsuported by Unicode 6.0 */
w += 0xf0000;
}
*snd = 0;
if (!w) {
w = s;
}
}
}
return w;
}
@ -324,6 +319,11 @@ mbfilter_sjis_emoji_kddi2unicode(int s, int *snd)
*snd = 0x0023; w = 0x20E3;
} else {
w = mb_tbl_code2uni_kddi1[si];
if (w > 0xf000) {
w += 0x10000;
} else if (w > 0xe000) { /* unsuported by Unicode 6.0 */
w += 0xf0000;
}
}
} else if (s >= mb_tbl_code2uni_kddi2_min && s <= mb_tbl_code2uni_kddi2_max) {
si = s - mb_tbl_code2uni_kddi2_min;
@ -337,6 +337,11 @@ mbfilter_sjis_emoji_kddi2unicode(int s, int *snd)
*snd = 0x0030; w = 0x20E3;
} else {
w = mb_tbl_code2uni_kddi2[si];
if (w > 0xf000) {
w += 0x10000;
} else if (w > 0xe000) { /* unsuported by Unicode 6.0 */
w += 0xf0000;
}
}
}
return w;
@ -353,13 +358,26 @@ mbfilter_sjis_emoji_sb2unicode(int s, int *snd)
si = s - mb_tbl_code2uni_sb1_min;
if (si == 0x006e || (si >= 0x007a && si <= 0x0083)) {
*snd = mb_tbl_code2uni_sb1[si];
if (*snd > 0xf000) {
*snd += 0x10000;
}
w = 0x20E3;
} else {
w = mb_tbl_code2uni_sb1[si];
if (w > 0xf000) {
w += 0x10000;
} else if (w > 0xe000) { /* unsuported by Unicode 6.0 */
w += 0xf0000;
}
}
} else if (s >= mb_tbl_code2uni_sb2_min && s <= mb_tbl_code2uni_sb2_max) {
si = s - mb_tbl_code2uni_sb2_min;
w = mb_tbl_code2uni_sb2[si];
if (w > 0xf000) {
w += 0x10000;
} else if (w > 0xe000) { /* unsuported by Unicode 6.0 */
w += 0xf0000;
}
} else if (s >= mb_tbl_code2uni_sb3_min && s <= mb_tbl_code2uni_sb3_max) {
si = s - mb_tbl_code2uni_sb3_min;
if (si >= 0x0069 && si <= 0x0072) {
@ -367,6 +385,11 @@ mbfilter_sjis_emoji_sb2unicode(int s, int *snd)
*snd = NFLAGS(nflags_s[c][0]); w = NFLAGS(nflags_s[c][1]);
} else {
w = mb_tbl_code2uni_sb3[si];
if (w > 0xf000) {
w += 0x10000;
} else if (w > 0xe000) { /* unsuported by Unicode 6.0 */
w += 0xf0000;
}
}
}
return w;
@ -408,11 +431,23 @@ mbfilter_unicode2sjis_emoji_docomo(int c, int *s1, mbfl_convert_filter *filter)
} else if (c == 0x00AE) {
*s1 = 0x29ba; match = 1;
} else if (c >= mb_tbl_uni_docomo2code2_min && c <= mb_tbl_uni_docomo2code2_max) {
match = mbfilter_conv_seq_tbl(c, s1, mb_tbl_uni_docomo2code2_key, mb_tbl_uni_docomo2code2_value,
sizeof(mb_tbl_uni_docomo2code2_key)/sizeof(int));
i = mbfl_bisec_srch2(c, mb_tbl_uni_docomo2code2_key, mb_tbl_uni_docomo2code2_len);
if (i >= 0) {
*s1 = mb_tbl_uni_docomo2code2_value[i];
match = 1;
}
} else if (c >= mb_tbl_uni_docomo2code3_min && c <= mb_tbl_uni_docomo2code3_max) {
match = mbfilter_conv_seq_tbl(c, s1, mb_tbl_uni_docomo2code3_key, mb_tbl_uni_docomo2code3_value,
sizeof(mb_tbl_uni_docomo2code3_key)/sizeof(int));
i = mbfl_bisec_srch2(c - 0x10000, mb_tbl_uni_docomo2code3_key, mb_tbl_uni_docomo2code3_len);
if (i >= 0) {
*s1 = mb_tbl_uni_docomo2code3_value[i];
match = 1;
}
} else if (c >= mb_tbl_uni_docomo2code5_min && c <= mb_tbl_uni_docomo2code5_max) {
i = mbfl_bisec_srch2(c - 0xf0000, mb_tbl_uni_docomo2code5_key, mb_tbl_uni_docomo2code5_len);
if (i >= 0) {
*s1 = mb_tbl_uni_docomo2code5_val[i];
match = 1;
}
}
}
@ -467,12 +502,24 @@ mbfilter_unicode2sjis_emoji_kddi(int c, int *s1, mbfl_convert_filter *filter)
} else if (c == 0x00AE) {
*s1 = 0x27dd; match = 1;
} else if (c >= mb_tbl_uni_kddi2code2_min && c <= mb_tbl_uni_kddi2code2_max) {
match = mbfilter_conv_seq_tbl(c, s1, mb_tbl_uni_kddi2code2_key, mb_tbl_uni_kddi2code2_value,
sizeof(mb_tbl_uni_kddi2code2_key)/sizeof(int));
i = mbfl_bisec_srch2(c, mb_tbl_uni_kddi2code2_key, mb_tbl_uni_kddi2code2_len);
if (i >= 0) {
*s1 = mb_tbl_uni_kddi2code2_value[i];
match = 1;
}
} else if (c >= mb_tbl_uni_kddi2code3_min && c <= mb_tbl_uni_kddi2code3_max) {
match = mbfilter_conv_seq_tbl(c, s1, mb_tbl_uni_kddi2code3_key, mb_tbl_uni_kddi2code3_value,
sizeof(mb_tbl_uni_kddi2code3_key)/sizeof(int));
}
i = mbfl_bisec_srch2(c - 0x10000, mb_tbl_uni_kddi2code3_key, mb_tbl_uni_kddi2code3_len);
if (i >= 0) {
*s1 = mb_tbl_uni_kddi2code3_value[i];
match = 1;
}
} else if (c >= mb_tbl_uni_kddi2code5_min && c <= mb_tbl_uni_kddi2code5_max) {
i = mbfl_bisec_srch2(c - 0xf0000, mb_tbl_uni_kddi2code5_key, mb_tbl_uni_kddi2code5_len);
if (i >= 0) {
*s1 = mb_tbl_uni_kddi2code5_val[i];
match = 1;
}
}
}
return match;
@ -525,14 +572,25 @@ mbfilter_unicode2sjis_emoji_sb(int c, int *s1, mbfl_convert_filter *filter)
} else if (c == 0x00AE) {
*s1 = 0x2856; match = 1;
} else if (c >= mb_tbl_uni_sb2code2_min && c <= mb_tbl_uni_sb2code2_max) {
match = mbfilter_conv_seq_tbl(c, s1, mb_tbl_uni_sb2code2_key, mb_tbl_uni_sb2code2_value,
sizeof(mb_tbl_uni_sb2code2_key)/sizeof(int));
i = mbfl_bisec_srch2(c, mb_tbl_uni_sb2code2_key, mb_tbl_uni_sb2code2_len);
if (i >= 0) {
*s1 = mb_tbl_uni_sb2code2_value[i];
match = 1;
}
} else if (c >= mb_tbl_uni_sb2code3_min && c <= mb_tbl_uni_sb2code3_max) {
match = mbfilter_conv_seq_tbl(c, s1, mb_tbl_uni_sb2code3_key, mb_tbl_uni_sb2code3_value,
sizeof(mb_tbl_uni_sb2code3_key)/sizeof(int));
}
i = mbfl_bisec_srch2(c - 0x10000, mb_tbl_uni_sb2code3_key, mb_tbl_uni_sb2code3_len);
if (i >= 0) {
*s1 = mb_tbl_uni_sb2code3_value[i];
match = 1;
}
} else if (c >= mb_tbl_uni_sb2code5_min && c <= mb_tbl_uni_sb2code5_max) {
i = mbfl_bisec_srch2(c - 0xf0000, mb_tbl_uni_sb2code5_key, mb_tbl_uni_sb2code5_len);
if (i >= 0) {
*s1 = mb_tbl_uni_sb2code5_val[i];
match = 1;
}
}
}
return match;
}
@ -545,6 +603,7 @@ mbfl_filt_conv_sjis_mobile_wchar(int c, mbfl_convert_filter *filter)
int c1, s, s1, s2, w;
int snd = 0;
retry:
switch (filter->status) {
case 0:
if (c >= 0 && c < 0x80) { /* latin */
@ -632,34 +691,37 @@ mbfl_filt_conv_sjis_mobile_wchar(int c, mbfl_convert_filter *filter)
CK((*filter->output_function)(w, filter->data));
}
break;
/* ESC : Softbank Emoji */
case 2:
if (filter->from->no_encoding == mbfl_no_encoding_sjis_sb &&
c == 0x24) {
filter->cache = c;
filter->status = 3;
filter->status++;
} else {
filter->cache = 0;
filter->status = 0;
CK((*filter->output_function)(0x1b, filter->data));
goto retry;
}
break;
/* ESC $ : Softbank Emoji */
case 3:
/* Softbank Emoji: ESC $ [GEFOPQ] X 0x0f */
if (filter->from->no_encoding == mbfl_no_encoding_sjis_sb &&
((c >= 0x45 && c <= 0x47) || (c >= 0x4f && c <= 0x51))) {
filter->cache = c;
filter->status = 4;
filter->status++;
} else {
filter->cache = 0;
filter->status = 0;
CK((*filter->output_function)(0x1b, filter->data));
CK((*filter->output_function)(0x24, filter->data));
goto retry;
}
break;
/* ESC [GEFOPQ] : Softbank Emoji */
case 4:
/* Softbank Emoji Web code: ESC $ [GEFOPQ] X 0x0f */
w = 0;
if (filter->from->no_encoding == mbfl_no_encoding_sjis_sb) {
c1 = filter->cache;
@ -684,10 +746,10 @@ mbfl_filt_conv_sjis_mobile_wchar(int c, mbfl_convert_filter *filter)
}
s = (s1 - 0x21)*94 + s2 - 0x21;
w = mbfilter_sjis_emoji_sb2unicode(s, &snd);
if (w > 0 && snd > 0) {
CK((*filter->output_function)(snd, filter->data));
}
if (w > 0) {
if (snd > 0) {
CK((*filter->output_function)(snd, filter->data));
}
CK((*filter->output_function)(w, filter->data));
}
}
@ -697,12 +759,10 @@ mbfl_filt_conv_sjis_mobile_wchar(int c, mbfl_convert_filter *filter)
c1 = filter->cache;
filter->cache = 0;
filter->status = 0;
w = c & MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(0x1b, filter->data));
CK((*filter->output_function)(0x24, filter->data));
CK((*filter->output_function)(c1 & 0xff, filter->data));
CK((*filter->output_function)(w, filter->data));
goto retry;
}
break;

View File

@ -59,7 +59,7 @@ int mbfilter_unicode2sjis_emoji_docomo(int c, int *s1, mbfl_convert_filter *filt
int mbfilter_unicode2sjis_emoji_kddi(int c, int *s1, mbfl_convert_filter *filter);
int mbfilter_unicode2sjis_emoji_sb(int c, int *s1, mbfl_convert_filter *filter);
int mbfilter_conv_map_tbl(int c, int *w, const int map[][3], int n);
int mbfilter_conv_r_map_tbl(int c, int *w, const int map[][3], int n);
int mbfilter_conv_map_tbl(int c, int *w, const unsigned short map[][3], int n);
int mbfilter_conv_r_map_tbl(int c, int *w, const unsigned short map[][3], int n);
#endif /* MBFL_MBFILTER_SJIS_MOBILE_H */

View File

@ -59,6 +59,7 @@
#include "filters/mbfilter_jis.h"
#include "filters/mbfilter_iso2022_jp_ms.h"
#include "filters/mbfilter_iso2022jp_2004.h"
#include "filters/mbfilter_iso2022jp_mobile.h"
#include "filters/mbfilter_euc_jp.h"
#include "filters/mbfilter_euc_jp_2004.h"
#include "filters/mbfilter_euc_jp_win.h"
@ -132,6 +133,8 @@ const struct mbfl_convert_vtbl *mbfl_convert_filter_list[] = {
&vtbl_wchar_2022jpms,
&vtbl_2022jp_2004_wchar,
&vtbl_wchar_2022jp_2004,
&vtbl_2022jp_kddi_wchar,
&vtbl_wchar_2022jp_kddi,
&vtbl_eucjpwin_wchar,
&vtbl_wchar_eucjpwin,
&vtbl_eucjp2004_wchar,

View File

@ -65,6 +65,7 @@
#include "filters/mbfilter_jis.h"
#include "filters/mbfilter_iso2022_jp_ms.h"
#include "filters/mbfilter_iso2022jp_2004.h"
#include "filters/mbfilter_iso2022jp_mobile.h"
#include "filters/mbfilter_euc_jp.h"
#include "filters/mbfilter_euc_jp_win.h"
#include "filters/mbfilter_euc_jp_2004.h"
@ -212,6 +213,7 @@ static const mbfl_encoding *mbfl_encoding_ptr_list[] = {
&mbfl_encoding_cp850,
&mbfl_encoding_jis_ms,
&mbfl_encoding_2022jp_2004,
&mbfl_encoding_2022jp_kddi,
&mbfl_encoding_cp50220,
&mbfl_encoding_cp50220raw,
&mbfl_encoding_cp50221,

View File

@ -84,6 +84,7 @@ enum mbfl_no_encoding {
mbfl_no_encoding_jis,
mbfl_no_encoding_2022jp,
mbfl_no_encoding_2022jp_2004,
mbfl_no_encoding_2022jp_kddi,
mbfl_no_encoding_2022jpms,
mbfl_no_encoding_gb18030,
mbfl_no_encoding_cp1252,

View File

@ -55,6 +55,7 @@
#include "filters/mbfilter_jis.h"
#include "filters/mbfilter_iso2022_jp_ms.h"
#include "filters/mbfilter_iso2022jp_2004.h"
#include "filters/mbfilter_iso2022jp_mobile.h"
#include "filters/mbfilter_euc_jp.h"
#include "filters/mbfilter_euc_jp_win.h"
#include "filters/mbfilter_euc_jp_2004.h"
@ -122,6 +123,7 @@ static const struct mbfl_identify_vtbl *mbfl_identify_filter_list[] = {
&vtbl_identify_2022jp,
&vtbl_identify_2022jpms,
&vtbl_identify_2022jp_2004,
&vtbl_identify_2022jp_kddi,
&vtbl_identify_cp51932,
&vtbl_identify_sjis_docomo,
&vtbl_identify_sjis_kddi,