*
* 3. This notice may not be removed or altered from any source distribution.
*/
-#define NKF_VERSION "2.0.9"
-#define NKF_RELEASE_DATE "2009-06-23"
+#define NKF_VERSION "2.1.1"
+#define NKF_RELEASE_DATE "2010-01-05"
#define COPY_RIGHT \
"Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
- "Copyright (C) 1996-2009, The nkf Project."
+ "Copyright (C) 1996-2010, The nkf Project."
#include "config.h"
#include "nkf.h"
} encoding_name_to_id_table[] = {
{"US-ASCII", ASCII},
{"ASCII", ASCII},
+ {"646", ASCII},
+ {"ROMAN8", ASCII},
{"ISO-2022-JP", ISO_2022_JP},
{"ISO2022JP-CP932", CP50220},
{"CP50220", CP50220},
{"ISO-2022-JP-2004", ISO_2022_JP_2004},
{"SHIFT_JIS", SHIFT_JIS},
{"SJIS", SHIFT_JIS},
+ {"PCK", SHIFT_JIS},
{"WINDOWS-31J", WINDOWS_31J},
{"CSWINDOWS31J", WINDOWS_31J},
{"CP932", WINDOWS_31J},
int shift = 20;
c &= VALUE_MASK;
while(shift >= 0){
- if(c >= 1<<shift){
+ if(c >= NKF_INT32_C(1)<<shift){
while(shift >= 0){
(*f)(0, bin2hex(c>>shift));
shift -= 4;
static nkf_char
w_iconv16(nkf_char c2, nkf_char c1, nkf_char c0)
{
- return 0;
+ (*oconv)(c2, c1);
+ return 16; /* different from w_iconv32 */
}
static nkf_char
w_iconv32(nkf_char c2, nkf_char c1, nkf_char c0)
{
- return 0;
+ (*oconv)(c2, c1);
+ return 32; /* different from w_iconv16 */
}
static size_t
}
static int
-h_conv(FILE *f, int c1, int c2)
+h_conv(FILE *f, nkf_char c1, nkf_char c2)
{
- int ret, c4, c3;
+ int ret;
int hold_index;
-
+ nkf_char c3, c4;
/** it must NOT be in the kanji shifte sequence */
/** it must NOT be written in JIS7 */
(const unsigned char *)"\075?ISO-8859-1?Q?",
(const unsigned char *)"\075?ISO-8859-1?B?",
(const unsigned char *)"\075?ISO-2022-JP?B?",
+ (const unsigned char *)"\075?ISO-2022-JP?B?",
(const unsigned char *)"\075?ISO-2022-JP?Q?",
#if defined(UTF8_INPUT_ENABLE)
(const unsigned char *)"\075?UTF-8?B?",
};
static const nkf_char mime_encode[] = {
- EUC_JP, SHIFT_JIS, ISO_8859_1, ISO_8859_1, JIS_X_0208, JIS_X_0201_1976_K,
+ EUC_JP, SHIFT_JIS, ISO_8859_1, ISO_8859_1, JIS_X_0208, JIS_X_0201_1976_K, JIS_X_0201_1976_K,
#if defined(UTF8_INPUT_ENABLE)
UTF_8, UTF_8,
#endif
};
static const nkf_char mime_encode_method[] = {
- 'B', 'B','Q', 'B', 'B', 'Q',
+ 'B', 'B','Q', 'B', 'B', 'B', 'Q',
#if defined(UTF8_INPUT_ENABLE)
'B', 'Q',
#endif
}
if (c1=='='&&c2<SP) { /* this is soft wrap */
while((c1 = (*i_mgetc)(f)) <=SP) {
- if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
+ if (c1 == EOF) return (EOF);
}
mime_decode_mode = 'Q'; /* still in MIME */
goto restart_mime_q;
base64_count = 1;
}
} else {
- if (base64_count + mimeout_state.count/3*4> 66) {
+ if (!(c2 == 0 && (c1 == CR || c1 == LF)) &&
+ base64_count + mimeout_state.count/3*4> 66) {
(*o_base64conv)(EOF,0);
OCONV_NEWLINE((*o_base64conv));
(*o_base64conv)(0,SP);
return;
}
}
- (*o_mputc)(c);
- base64_count++;
+ if (c != 0x1B) {
+ (*o_mputc)(c);
+ base64_count++;
+ return;
+ }
}
- return;
}
if (mimeout_mode <= 0) {
- if (c <= DEL && (output_mode==ASCII ||output_mode == ISO_8859_1)) {
+ if (c <= DEL && (output_mode==ASCII || output_mode == ISO_8859_1 ||
+ output_mode == UTF_8)) {
if (nkf_isspace(c)) {
int flag = 0;
if (mimeout_mode == -1) {
}
}else{
/* mimeout_mode == 'B', 1, 2 */
- if ( c<=DEL && (output_mode==ASCII ||output_mode == ISO_8859_1)) {
+ if (c <= DEL && (output_mode==ASCII || output_mode == ISO_8859_1 ||
+ output_mode == UTF_8)) {
if (lastchar == CR || lastchar == LF){
if (nkf_isblank(c)) {
for (i=0;i<mimeout_state.count;i++) {
mimeout_addchar(mimeout_state.buf[i]);
}
mimeout_state.count = 0;
- } else if (SP<c && c<DEL) {
+ } else {
eof_mime();
for (i=0;i<mimeout_state.count;i++) {
(*o_mputc)(mimeout_state.buf[i]);
set_output_encoding(output_encoding);
oconv = nkf_enc_to_oconv(output_encoding);
o_putc = std_putc;
+ if (nkf_enc_unicode_p(output_encoding))
+ output_mode = UTF_8;
/* replace continucation module, from output side */
(c4 = (*i_getc)(f)) != EOF) {
nkf_iconv_utf_32(c1, c2, c3, c4);
}
- (*i_ungetc)(EOF, f);
+ goto finished;
}
else if (iconv == w_iconv16) {
while ((c1 = (*i_getc)(f)) != EOF &&
nkf_iconv_utf_16(c1, c2, c3, c4);
}
}
- (*i_ungetc)(EOF, f);
+ goto finished;
}
#endif
/* goto next_word */
}
+finished:
/* epilogue */
(*iconv)(EOF, 0, 0);
if (!input_codename)