📄 nkflib.c
字号:
c2 = c1; NEXT; /* goto next_byte */ } else if(c1 == '=' && mime_f && !mime_mode ) { if((c1 = sgetc(f)) == EOF) { (*oconv)(0, '='); LAST; } else if(c1 == '?') { /* =? is mime conversion start sequence */ if(mime_begin(f) == EOF) /* check in detail */ LAST; else NEXT; } else { (*oconv)(0, '='); sungetc(c1,f); NEXT; } } else if(c1 == '$' && broken_f && !mime_mode) { /* try to recover missing escape */ if((c1 = GETC(f)) == EOF) { (*oconv)(0, '$'); LAST; } else if(c1 == '@'|| c1 == 'B') { /* in case of Kanji in ESC sequence */ input_mode = X0208; shift_mode = FALSE; NEXT; } else { /* sorry */ (*oconv)(0, '$'); (*oconv)(0, c1); NEXT; } } else SEND; } else if(c1 == SI) { shift_mode = FALSE; NEXT; } else if(c1 == SO) { shift_mode = TRUE; NEXT; } else if(c1 == ESC ) { if((c1 = GETC(f)) == EOF) { (*oconv)(0, ESC); LAST; } else if(c1 == '$') { if((c1 = GETC(f)) == EOF) { (*oconv)(0, ESC); (*oconv)(0, '$'); LAST; } else if(c1 == '@'|| c1 == 'B') { /* This is kanji introduction */ input_mode = X0208; shift_mode = FALSE; NEXT; } else if(c1 == '(') { if((c1 = GETC(f)) == EOF) { (*oconv)(0, ESC); (*oconv)(0, '$'); (*oconv)(0, '('); LAST; } else if(c1 == '@'|| c1 == 'B') { /* This is kanji introduction */ input_mode = X0208; shift_mode = FALSE; NEXT; } else { (*oconv)(0, ESC); (*oconv)(0, '$'); (*oconv)(0, '('); (*oconv)(0, c1); NEXT; } } else if(broken_f&0x2) { input_mode = X0208; shift_mode = FALSE; NEXT; } else { (*oconv)(0, ESC); (*oconv)(0, '$'); (*oconv)(0, c1); NEXT; } } else if(c1 == '(') { if((c1 = GETC(f)) == EOF) { (*oconv)(0, ESC); (*oconv)(0, '('); LAST; } else { if(c1 == 'I') { /* This is X0201 kana introduction */ input_mode = X0201; shift_mode = X0201; NEXT; } else if(c1 == 'B' || c1 == 'J' || c1 == 'H') { /* This is X0208 kanji introduction */ input_mode = ASCII; shift_mode = FALSE; NEXT; } else if(broken_f&0x2) { input_mode = ASCII; shift_mode = FALSE; NEXT; } else { (*oconv)(0, ESC); (*oconv)(0, '('); /* maintain various input_mode here */ SEND; } } } else { /* lonely ESC */ (*oconv)(0, ESC); SEND; } } else if(c1 == NL && broken_f&4) { input_mode = ASCII; SEND; } else SEND; } /* send: */ if(input_mode == X0208) (*oconv)(c2, c1); /* this is JIS, not SJIS/EUC case */ else (*iconv)(c2, c1); /* can be EUC/SJIS */ c2 = 0; continue; /* goto next_word */ } /* epilogue */ (*iconv)(EOF, 0); return 1;}inth_conv(SFILE *f, int c2, int c1){ int wc; /** it must NOT be in the kanji shifte sequence */ /** it must NOT be written in JIS7 */ /** and it must be after 2 byte 8bit code */ hold_count = 0; push_hold_buf(c2, c1); c2 = 0; while ((c1 = GETC(f)) != EOF) { if(c2) { /* second byte */ if(!estab_f) { /* not established */ if(c1 > SSP) { /* it is still ambiguious yet */ SEND; } else if(c1 < AT) { /* ignore bogus first byte */ c2 = 0; SEND; } else { /* now established */ /* it seems to be MS Kanji */ estab_f = TRUE; iconv = s_iconv; SEND; } } else SEND; } else { /* First byte */ if(c1 > DEL) { /* 8th bit is on */ if(c1 < SSP) { /* it seems to be MS Kanji */ estab_f = TRUE; iconv = s_iconv; } else if(c1 < 0xe0) { /* it seems to be EUC */ estab_f = TRUE; iconv = oconv; } else { /* still ambiguious */ } c2 = c1; NEXT; } else /* 7 bit code , then send without any process */ SEND; } /* send: */ if((push_hold_buf(c2, c1) == EOF) || estab_f) break; c2 = 0; continue; } /** now, ** 1) EOF is detected, or ** 2) Code is established, or ** 3) Buffer is FULL (but last word is pushed) ** ** in 1) and 3) cases, we continue to use ** Kanji codes by oconv and leave estab_f unchanged. **/ for (wc = 0; wc < hold_count; wc += 2) { c2 = hold_buf[wc]; c1 = hold_buf[wc+1]; (*iconv)(c2, c1); } return VOIDVOID;}intpush_hold_buf(int c2, int c1){ if(hold_count >= HOLD_SIZE*2) return (EOF); hold_buf[hold_count++] = c2; hold_buf[hold_count++] = c1; return ((hold_count >= HOLD_SIZE*2) ? EOF : hold_count);}ints_iconv(int c2, int c1){ if((c2 == EOF) || (c2 == 0)) { /* NOP */ } else { c2 = c2 + c2 - ((c2 <= 0x9f) ? SJ0162 : SJ6394); if(c1 < 0x9f) c1 = c1 - ((c1 > DEL) ? SPACE : 0x1f); else { c1 = c1 - 0x7e; c2++; } } (*oconv)(c2, c1); return 1;}inte_oconv(int c2, int c1){ c2 = pre_convert(c1,c2); c1 = c1_return; if(fold_f) { switch(line_fold(c2,c1)) { case '\n': if(add_cr == TRUE) { sputchar('\r'); c1 = '\n'; } sputchar('\n'); break; case 0: return VOIDVOID; case '\r': c1 = '\n'; c2 = 0; break; case '\t': case ' ': c1 = ' '; c2 = 0; break; } } if(c2==DOUBLE_SPACE) { sputchar(' '); sputchar(' '); return VOIDVOID; } if(c2 == EOF) return VOIDVOID; else if(c2 == 0 && (c1&0x80)) { sputchar(SSO); sputchar(c1); } else if(c2 == 0) { if(c1 == '\n' && add_cr == TRUE) sputchar('\r'); if(c1 != '\r') sputchar(c1); else if(del_cr == FALSE) sputchar(c1); } else { if((c1<0x20 || 0x7e<c1) || (c2<0x20 || 0x7e<c2)) { estab_f = FALSE; return VOIDVOID; /* too late to rescue this char */ } sputchar(c2 | 0x080); sputchar(c1 | 0x080); } return VOIDVOID;}ints_oconv(int c2, int c1){ c2 = pre_convert(c1,c2); c1 = c1_return; if(fold_f) { switch(line_fold(c2,c1)) { case '\n': if(add_cr == TRUE) { sputchar('\r'); c1 = '\n'; } sputchar('\n'); break; case '\r': c1 = '\n'; c2 = 0; break; case 0: return VOIDVOID; case '\t': case ' ': c1 = ' '; c2 = 0; break; } } if(c2==DOUBLE_SPACE) { sputchar(' '); sputchar(' '); return VOIDVOID; } if(c2 == EOF) return VOIDVOID; else if(c2 == 0) { if(c1 == '\n' && add_cr == TRUE) sputchar('\r'); if(c1 != '\r') sputchar(c1); else if(del_cr == FALSE) sputchar(c1); } else { if((c1<0x20 || 0x7e<c1) || (c2<0x20 || 0x7e<c2)) { estab_f = FALSE; return VOIDVOID; /* too late to rescue this char */ } sputchar((((c2 - 1) >> 1) + ((c2 <= 0x5e) ? 0x71 : 0xb1))); sputchar((c1 + ((c2 & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e))); } return VOIDVOID;}intj_oconv(int c2, int c1){ c2 = pre_convert(c1,c2); c1 = c1_return; if(fold_f) { switch(line_fold(c2,c1)) { case '\n': if(output_mode) { sputchar(ESC); sputchar('('); sputchar(ascii_intro); } if(add_cr == TRUE) { sputchar('\r'); c1 = '\n'; } sputchar('\n'); output_mode = ASCII; break; case '\r': c1 = '\n'; c2 = 0; break; case '\t': case ' ': c1 = ' '; c2 = 0; break; case 0: return VOIDVOID; } } if(c2 == EOF) { if(output_mode) { sputchar(ESC); sputchar('('); sputchar(ascii_intro); } } else if(c2 == 0 && (c1 & 0x80)) { if(input_mode==X0201 || !iso8859_f) { if(output_mode!=X0201) { sputchar(ESC); sputchar('('); sputchar('I'); output_mode = X0201; } c1 &= 0x7f; } else { /* iso8859 introduction, or 8th bit on */ /* Can we convert in 7bit form using ESC-'-'-A ? Is this popular? */ } sputchar(c1); } else if(c2 == 0) { if(output_mode) { sputchar(ESC); sputchar('('); sputchar(ascii_intro); output_mode = ASCII; } if(c1 == '\n' && add_cr == TRUE) sputchar('\r'); if(c1 != '\r') sputchar(c1); else if(del_cr == FALSE) sputchar(c1); } else if(c2 == DOUBLE_SPACE) { if(output_mode) { sputchar(ESC); sputchar('('); sputchar(ascii_intro); output_mode = ASCII; } sputchar(' '); if(c1 == '\n' && add_cr == TRUE) sputchar('\r'); if(c1 != '\r') sputchar(c1); else if(del_cr == FALSE) sputchar(c1); } else { if(output_mode != X0208) { sputchar(ESC); sputchar('$'); sputchar(kanji_intro); output_mode = X0208; } if(c1<0x20 || 0x7e<c1) return VOIDVOID; if(c2<0x20 || 0x7e<c2) return VOIDVOID; sputchar(c2); if(c1 == '\n' && add_cr == TRUE) sputchar('\r'); if(c1 != '\r') sputchar(c1); else if(del_cr == FALSE)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -