Ruby: ext/nkf/nkf-utf8/nkf.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Enumerations | Functions | Variables
nkf.c File Reference
`#include "config.h"`
`#include "nkf.h"`
`#include "utf8tbl.h"`
`#include <assert.h>`

Go to the source code of this file.

## Data Structures
struct | nkf_native_encoding
struct | nkf_encoding
struct | input_code
struct | nkf_buf_t
struct | nkf_state_t

## Macros
#define | NKF_VERSION "2.1.5"
#define | NKF_RELEASE_DATE "2018-12-15"
#define | COPY_RIGHT
#define | FIXED_MIME 7
#define | STRICT_MIME 8
#define | BS 0x08
#define | TAB 0x09
#define | LF 0x0a
#define | CR 0x0d
#define | ESC 0x1b
#define | SP 0x20
#define | DEL 0x7f
#define | SI 0x0f
#define | SO 0x0e
#define | SS2 0x8e
#define | SS3 0x8f
#define | CRLF 0x0D0A
#define | is_alnum(c) (('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))
#define | nkf_toupper(c) (('a'<=c && c<='z')?(c-('a'-'A')):c)
#define | nkf_isoctal(c) ('0'<=c && c<='7')
#define | nkf_isdigit(c) ('0'<=c && c<='9')
#define | nkf_isxdigit(c) (nkf_isdigit(c) || ('a'<=c && c<='f') || ('A'<=c && c <= 'F'))
#define | nkf_isblank(c) (c == SP || c == TAB)
#define | nkf_isspace(c) (nkf_isblank(c) || c == CR || c == LF)
#define | nkf_isalpha(c) (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
#define | nkf_isalnum(c) (nkf_isdigit(c) || nkf_isalpha(c))
#define | nkf_isprint(c) (SP<=c && c<='~')
#define | nkf_isgraph(c) ('!'<=c && c<='~')
#define | hex2bin(c)
#define | bin2hex(c) ("0123456789ABCDEF"[c&15])
#define | is_eucg3(c2) (((unsigned short)c2 >> 8) == SS3)
#define | nkf_noescape_mime(c)
#define | is_ibmext_in_sjis(c2) (CP932_TABLE_BEGIN <= c2 && c2 <= CP932_TABLE_END)
#define | nkf_byte_jisx0201_katakana_p(c) (SP <= c && c <= 0x5F)
#define | HOLD_SIZE 1024
#define | IOBUF_SIZE 16384
#define | DEFAULT_J 'B'
#define | DEFAULT_R 'B'
#define | GETA1 0x22
#define | GETA2 0x2e
#define | UCS_MAP_ASCII 0
#define | UCS_MAP_MS 1
#define | UCS_MAP_CP932 2
#define | UCS_MAP_CP10001 3
#define | NKF_UNSPECIFIED (-TRUE)
#define | PREFIX_EUCG3 NKF_INT32_C(0x8F00)
#define | CLASS_MASK NKF_INT32_C(0xFF000000)
#define | CLASS_UNICODE NKF_INT32_C(0x01000000)
#define | VALUE_MASK NKF_INT32_C(0x00FFFFFF)
#define | UNICODE_BMP_MAX NKF_INT32_C(0x0000FFFF)
#define | UNICODE_MAX NKF_INT32_C(0x0010FFFF)
#define | nkf_char_euc3_new(c) ((c) | PREFIX_EUCG3)
#define | nkf_char_unicode_new(c) ((c) | CLASS_UNICODE)
#define | nkf_char_unicode_p(c) ((c & CLASS_MASK) == CLASS_UNICODE)
#define | nkf_char_unicode_bmp_p(c) ((c & VALUE_MASK) <= UNICODE_BMP_MAX)
#define | nkf_char_unicode_value_p(c) ((c & VALUE_MASK) <= UNICODE_MAX)
#define | UTF16_TO_UTF32(lead, trail) (((lead) << 10) + (trail) - NKF_INT32_C(0x35FDC00))
#define | FOLD_MARGIN 10
#define | DEFAULT_FOLD 60
#define | nkf_xfree(ptr) free(ptr)
#define | nkf_enc_name(enc) (enc)->name
#define | nkf_enc_to_index(enc) (enc)->id
#define | nkf_enc_to_base_encoding(enc) (enc)->base_encoding
#define | nkf_enc_to_iconv(enc) nkf_enc_to_base_encoding(enc)->iconv
#define | nkf_enc_to_oconv(enc) nkf_enc_to_base_encoding(enc)->oconv
#define | nkf_enc_asciicompat(enc)
#define | nkf_enc_unicode_p(enc)
#define | nkf_enc_cp5022x_p(enc)
#define | nkf_buf_length(buf) ((buf)->len)
#define | nkf_buf_empty_p(buf) ((buf)->len == 0)
#define | SJ0162 0x00e1 /* 01 - 62 ku offset */
#define | SJ6394 0x0161 /* 63 - 94 ku offset */
#define | X0213_SURROGATE_FIND(tbl, size, euc)
#define | NKF_ICONV_INVALID_CODE_RANGE -13
#define | NKF_ICONV_WAIT_COMBINING_CHAR -14
#define | NKF_ICONV_NOT_COMBINED -15
#define | NKF_ICONV_NEED_ONE_MORE_BYTE (size_t)-1
#define | NKF_ICONV_NEED_TWO_MORE_BYTES (size_t)-2
#define | output_ascii_escape_sequence(mode)
#define | OUTPUT_UTF8(val)
#define | OUTPUT_UTF16_BYTES(c1, c2)
#define | OUTPUT_UTF16(val)
#define | OUTPUT_UTF32(c)
#define | SCORE_L2 (1) /* Kanji Level 2 */
#define | SCORE_KANA (SCORE_L2 << 1) /* Halfwidth Katakana */
#define | SCORE_DEPEND (SCORE_KANA << 1) /* MD Characters */
#define | SCORE_CP932 (SCORE_DEPEND << 1) /* IBM extended characters */
#define | SCORE_X0212 (SCORE_CP932 << 1) /* JIS X 0212 */
#define | SCORE_X0213 (SCORE_X0212 << 1) /* JIS X 0213 */
#define | SCORE_NO_EXIST (SCORE_X0213 << 1) /* Undefined Characters */
#define | SCORE_iMIME (SCORE_NO_EXIST << 1) /* MIME selected */
#define | SCORE_ERROR (SCORE_iMIME << 1) /* Error */
#define | SCORE_INIT (SCORE_iMIME)
#define | STD_GC_BUFSIZE (256)
#define | char_size(c2, c1) (c2?2:1)
#define | rot13(c)
#define | rot47(c)
#define | RANGE_NUM_MAX 18
#define | MIME_BUF_SIZE (1024) /* 2^n ring buffer */
#define | MIME_BUF_MASK (MIME_BUF_SIZE-1)
#define | mime_input_buf(n) mime_input_state.buf[(n)&MIME_BUF_MASK]
#define | MAXRECOVER 20
#define | MIMEOUT_BUF_LENGTH 74
#define | NEXT continue /* no output, get next */
#define | SKIP c2=0;continue /* no output, get next */
#define | MORE c2=c1;continue /* need one more byte */
#define | SEND (void)0 /* output c1 and c2, get next */
#define | LAST break /* end of loop, go closing */
#define | set_input_mode(mode)

## Enumerations
enum | byte_order { ENDIAN_BIG = 1 , ENDIAN_LITTLE = 2 , ENDIAN_2143 = 3 , ENDIAN_3412 = 4 }
enum | nkf_encodings { ASCII , ISO_8859_1 , ISO_2022_JP , CP50220 , CP50221 , CP50222 , ISO_2022_JP_1 , ISO_2022_JP_3 , ISO_2022_JP_2004 , SHIFT_JIS , WINDOWS_31J , CP10001 , EUC_JP , EUCJP_NKF , CP51932 , EUCJP_MS , EUCJP_ASCII , SHIFT_JISX0213 , SHIFT_JIS_2004 , EUC_JISX0213 , EUC_JIS_2004 , UTF_8 , UTF_8N , UTF_8_BOM , UTF8_MAC , UTF_16 , UTF_16BE , UTF_16BE_BOM , UTF_16LE , UTF_16LE_BOM , UTF_32 , UTF_32BE , UTF_32BE_BOM , UTF_32LE , UTF_32LE_BOM , BINARY , NKF_ENCODING_TABLE_SIZE , JIS_X_0201_1976_K = 0x1013 , JIS_X_0208 = 0x1168 , JIS_X_0212 = 0x1159 , JIS_X_0213_2 = 0x1229 , JIS_X_0213_1 = 0x1233 }

## Functions
int | main (int argc, char **argv)

## Variables
nkf_native_encoding | NkfEncodingASCII = { "ASCII", e_iconv, e_oconv }
nkf_native_encoding | NkfEncodingISO_2022_JP = { "ISO-2022-JP", e_iconv, j_oconv }
nkf_native_encoding | NkfEncodingShift_JIS = { "Shift_JIS", s_iconv, s_oconv }
nkf_native_encoding | NkfEncodingEUC_JP = { "EUC-JP", e_iconv, e_oconv }
nkf_native_encoding | NkfEncodingUTF_8 = { "UTF-8", w_iconv, w_oconv }
nkf_native_encoding | NkfEncodingUTF_16 = { "UTF-16", w_iconv16, w_oconv16 }
nkf_native_encoding | NkfEncodingUTF_32 = { "UTF-32", w_iconv32, w_oconv32 }
nkf_encoding | nkf_encoding_table []
struct {
const char * name
const int id
} | encoding_name_to_id_table []
struct input_code | input_code_list []
nkf_char(* | mime_priority_func [])(nkf_char c2, nkf_char c1, nkf_char c0)

## Macro Definition Documentation

## ◆ bin2hex

#define bin2hex | ( |  | c | ) | ("0123456789ABCDEF"[c&15])

Definition at line 295 of file nkf.c.

## ◆ BS

#define BS 0x08

Definition at line 70 of file nkf.c.

## ◆ char_size

#define char_size | ( |  | c2,
|  |  | c1
| ) |  | (c2?2:1)

Definition at line 3824 of file nkf.c.

## ◆ CLASS_MASK

#define CLASS_MASK NKF_INT32_C(0xFF000000)

Definition at line 423 of file nkf.c.

## ◆ CLASS_UNICODE

#define CLASS_UNICODE NKF_INT32_C(0x01000000)

Definition at line 424 of file nkf.c.

## ◆ COPY_RIGHT

#define COPY_RIGHT

Value:
"Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
"Copyright (C) 1996-2018, The nkf Project."

Definition at line 25 of file nkf.c.

## ◆ CR

#define CR 0x0d

Definition at line 73 of file nkf.c.

## ◆ CRLF

#define CRLF 0x0D0A

Definition at line 81 of file nkf.c.

## ◆ DEFAULT_FOLD

#define DEFAULT_FOLD 60

Definition at line 505 of file nkf.c.

## ◆ DEFAULT_J

#define DEFAULT_J 'B'

Definition at line 311 of file nkf.c.

## ◆ DEFAULT_R

#define DEFAULT_R 'B'

Definition at line 312 of file nkf.c.

## ◆ DEL

#define DEL 0x7f

Definition at line 76 of file nkf.c.

## ◆ ESC

#define ESC 0x1b

Definition at line 74 of file nkf.c.

## ◆ FIXED_MIME

#define FIXED_MIME 7

Definition at line 57 of file nkf.c.

## ◆ FOLD_MARGIN

#define FOLD_MARGIN 10

Definition at line 504 of file nkf.c.

## ◆ GETA1

#define GETA1 0x22

Definition at line 315 of file nkf.c.

## ◆ GETA2

#define GETA2 0x2e

Definition at line 316 of file nkf.c.

## ◆ hex2bin

#define hex2bin | ( |  | c | ) |

Value:
(('0'<=c&&c<='9') ? (c-'0') : \
('A'<=c&&c<='F') ? (c-'A'+10) : \
('a'<=c&&c<='f') ? (c-'a'+10) : 0)

Definition at line 292 of file nkf.c.

## ◆ HOLD_SIZE

#define HOLD_SIZE 1024

Definition at line 304 of file nkf.c.

## ◆ IOBUF_SIZE

#define IOBUF_SIZE 16384

Definition at line 308 of file nkf.c.

## ◆ is_alnum

#define is_alnum | ( |  | c | ) | (('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))

Definition at line 278 of file nkf.c.

## ◆ is_eucg3

#define is_eucg3 | ( |  | c2 | ) | (((unsigned short)c2 >> 8) == SS3)

Definition at line 296 of file nkf.c.

## ◆ is_ibmext_in_sjis

#define is_ibmext_in_sjis | ( |  | c2 | ) | (CP932_TABLE_BEGIN <= c2 && c2 <= CP932_TABLE_END)

Definition at line 301 of file nkf.c.

## ◆ LAST

#define LAST break /* end of loop, go closing */

Definition at line 5838 of file nkf.c.

## ◆ LF

#define LF 0x0a

Definition at line 72 of file nkf.c.

## ◆ MAXRECOVER

#define MAXRECOVER 20

Definition at line 4329 of file nkf.c.

## ◆ MIME_BUF_MASK

#define MIME_BUF_MASK (MIME_BUF_SIZE-1)

Definition at line 4319 of file nkf.c.

## ◆ MIME_BUF_SIZE

#define MIME_BUF_SIZE (1024) /* 2^n ring buffer */

Definition at line 4318 of file nkf.c.

## ◆ mime_input_buf

#define mime_input_buf | ( |  | n | ) | mime_input_state.buf[(n)&MIME_BUF_MASK]

Definition at line 4320 of file nkf.c.

## ◆ MIMEOUT_BUF_LENGTH

#define MIMEOUT_BUF_LENGTH 74

Definition at line 5052 of file nkf.c.

## ◆ MORE

#define MORE c2=c1;continue /* need one more byte */

Definition at line 5836 of file nkf.c.

## ◆ NEXT

#define NEXT continue /* no output, get next */

Definition at line 5834 of file nkf.c.

## ◆ nkf_buf_empty_p

#define nkf_buf_empty_p | ( |  | buf | ) | ((buf)->len == 0)

Definition at line 860 of file nkf.c.

## ◆ nkf_buf_length

#define nkf_buf_length | ( |  | buf | ) | ((buf)->len)

Definition at line 859 of file nkf.c.

## ◆ nkf_byte_jisx0201_katakana_p

#define nkf_byte_jisx0201_katakana_p | ( |  | c | ) | (SP <= c && c <= 0x5F)

Definition at line 302 of file nkf.c.

## ◆ nkf_char_euc3_new

#define nkf_char_euc3_new | ( |  | c | ) | ((c) | PREFIX_EUCG3)

Definition at line 428 of file nkf.c.

## ◆ nkf_char_unicode_bmp_p

#define nkf_char_unicode_bmp_p | ( |  | c | ) | ((c & VALUE_MASK) <= UNICODE_BMP_MAX)

Definition at line 431 of file nkf.c.

## ◆ nkf_char_unicode_new

#define nkf_char_unicode_new | ( |  | c | ) | ((c) | CLASS_UNICODE)

Definition at line 429 of file nkf.c.

## ◆ nkf_char_unicode_p

#define nkf_char_unicode_p | ( |  | c | ) | ((c & CLASS_MASK) == CLASS_UNICODE)

Definition at line 430 of file nkf.c.

## ◆ nkf_char_unicode_value_p

#define nkf_char_unicode_value_p | ( |  | c | ) | ((c & VALUE_MASK) <= UNICODE_MAX)

Definition at line 432 of file nkf.c.

## ◆ nkf_enc_asciicompat

#define nkf_enc_asciicompat | ( |  | enc | ) |

Value:
(\
nkf_enc_to_base_encoding(enc) == &NkfEncodingASCII ||\
nkf_enc_to_base_encoding(enc) == &NkfEncodingISO_2022_JP)
NkfEncodingISO_2022_JP
nkf_native_encoding NkfEncodingISO_2022_JP
Definition: nkf.c:154
NkfEncodingASCII
nkf_native_encoding NkfEncodingASCII
Definition: nkf.c:153

Definition at line 763 of file nkf.c.

## ◆ nkf_enc_cp5022x_p

#define nkf_enc_cp5022x_p | ( |  | enc | ) |

Value:
(\
nkf_enc_to_index(enc) == CP50220 ||\
nkf_enc_to_index(enc) == CP50221 ||\
nkf_enc_to_index(enc) == CP50222)
CP50221
@ CP50221
Definition: nkf.c:91
CP50220
@ CP50220
Definition: nkf.c:90
CP50222
@ CP50222
Definition: nkf.c:92

Definition at line 770 of file nkf.c.

## ◆ nkf_enc_name

#define nkf_enc_name | ( |  | enc | ) | (enc)->name

Definition at line 758 of file nkf.c.

## ◆ nkf_enc_to_base_encoding

#define nkf_enc_to_base_encoding | ( |  | enc | ) | (enc)->base_encoding

Definition at line 760 of file nkf.c.

## ◆ nkf_enc_to_iconv

#define nkf_enc_to_iconv | ( |  | enc | ) | nkf_enc_to_base_encoding(enc)->iconv

Definition at line 761 of file nkf.c.

## ◆ nkf_enc_to_index

#define nkf_enc_to_index | ( |  | enc | ) | (enc)->id

Definition at line 759 of file nkf.c.

## ◆ nkf_enc_to_oconv

#define nkf_enc_to_oconv | ( |  | enc | ) | nkf_enc_to_base_encoding(enc)->oconv

Definition at line 762 of file nkf.c.

## ◆ nkf_enc_unicode_p

#define nkf_enc_unicode_p | ( |  | enc | ) |

Value:
(\
nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_8 ||\
nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_16 ||\
nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_32)
NkfEncodingUTF_8
nkf_native_encoding NkfEncodingUTF_8
Definition: nkf.c:157
NkfEncodingUTF_32
nkf_native_encoding NkfEncodingUTF_32
Definition: nkf.c:159
NkfEncodingUTF_16
nkf_native_encoding NkfEncodingUTF_16
Definition: nkf.c:158

Definition at line 766 of file nkf.c.

## ◆ NKF_ICONV_INVALID_CODE_RANGE

#define NKF_ICONV_INVALID_CODE_RANGE -13

Definition at line 2332 of file nkf.c.

## ◆ NKF_ICONV_NEED_ONE_MORE_BYTE

#define NKF_ICONV_NEED_ONE_MORE_BYTE (size_t)-1

Definition at line 2404 of file nkf.c.

## ◆ NKF_ICONV_NEED_TWO_MORE_BYTES

#define NKF_ICONV_NEED_TWO_MORE_BYTES (size_t)-2

Definition at line 2405 of file nkf.c.

## ◆ NKF_ICONV_NOT_COMBINED

#define NKF_ICONV_NOT_COMBINED -15

Definition at line 2334 of file nkf.c.

## ◆ NKF_ICONV_WAIT_COMBINING_CHAR

#define NKF_ICONV_WAIT_COMBINING_CHAR -14

Definition at line 2333 of file nkf.c.

## ◆ nkf_isalnum

#define nkf_isalnum | ( |  | c | ) | (nkf_isdigit(c) || nkf_isalpha(c))

Definition at line 289 of file nkf.c.

## ◆ nkf_isalpha

#define nkf_isalpha | ( |  | c | ) | (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))

Definition at line 288 of file nkf.c.

## ◆ nkf_isblank

#define nkf_isblank | ( |  | c | ) | (c == SP || c == TAB)

Definition at line 286 of file nkf.c.

## ◆ nkf_isdigit

#define nkf_isdigit | ( |  | c | ) | ('0'<=c && c<='9')

Definition at line 284 of file nkf.c.

## ◆ nkf_isgraph

#define nkf_isgraph | ( |  | c | ) | ('!'<=c && c<='~')

Definition at line 291 of file nkf.c.

## ◆ nkf_isoctal

#define nkf_isoctal | ( |  | c | ) | ('0'<=c && c<='7')

Definition at line 283 of file nkf.c.

## ◆ nkf_isprint

#define nkf_isprint | ( |  | c | ) | (SP<=c && c<='~')

Definition at line 290 of file nkf.c.

## ◆ nkf_isspace

#define nkf_isspace | ( |  | c | ) | (nkf_isblank(c) || c == CR || c == LF)

Definition at line 287 of file nkf.c.

## ◆ nkf_isxdigit

#define nkf_isxdigit | ( |  | c | ) | (nkf_isdigit(c) || ('a'<=c && c<='f') || ('A'<=c && c <= 'F'))

Definition at line 285 of file nkf.c.

## ◆ nkf_noescape_mime

#define nkf_noescape_mime | ( |  | c | ) |

Value:
((c == CR) || (c == LF) || \
((c > SP) && (c < DEL) && (c != '?') && (c != '=') && (c != '_') \
&& (c != '(') && (c != ')') && (c != '.') && (c != 0x22)))
LF
#define LF
Definition: nkf.c:72
CR
#define CR
Definition: nkf.c:73
DEL
#define DEL
Definition: nkf.c:76
SP
#define SP
Definition: nkf.c:75

Definition at line 297 of file nkf.c.

## ◆ NKF_RELEASE_DATE

#define NKF_RELEASE_DATE "2018-12-15"

Definition at line 24 of file nkf.c.

## ◆ nkf_toupper

#define nkf_toupper | ( |  | c | ) | (('a'<=c && c<='z')?(c-('a'-'A')):c)

Definition at line 282 of file nkf.c.

## ◆ NKF_UNSPECIFIED

#define NKF_UNSPECIFIED (-TRUE)

Definition at line 387 of file nkf.c.

## ◆ NKF_VERSION

#define NKF_VERSION "2.1.5"

Definition at line 23 of file nkf.c.

## ◆ nkf_xfree

#define nkf_xfree | ( |  | ptr | ) | free(ptr)

Definition at line 714 of file nkf.c.

## ◆ output_ascii_escape_sequence

#define output_ascii_escape_sequence | ( |  | mode | ) |

Value:
do { \
if (output_mode != ASCII && output_mode != ISO_8859_1) { \
(*o_putc)(ESC); \
(*o_putc)('('); \
(*o_putc)(ascii_intro); \
output_mode = mode; \
} \
} while (0)
mode
const char int mode
Definition: ioapi.h:137
ESC
#define ESC
Definition: nkf.c:74
ISO_8859_1
@ ISO_8859_1
Definition: nkf.c:88
ASCII
@ ASCII
Definition: nkf.c:87

Definition at line 2552 of file nkf.c.

## ◆ OUTPUT_UTF16

#define OUTPUT_UTF16 | ( |  | val | ) |

Value:
do { \
if (nkf_char_unicode_bmp_p(val)) { \
c2 = (val >> 8) & 0xff; \
c1 = val & 0xff; \
OUTPUT_UTF16_BYTES(c1, c2); \
} else { \
val &= VALUE_MASK; \
if (val <= UNICODE_MAX) { \
c2 = (val >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */ \
c1 = (val & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */ \
OUTPUT_UTF16_BYTES(c2 & 0xff, (c2 >> 8) & 0xff); \
OUTPUT_UTF16_BYTES(c1 & 0xff, (c1 >> 8) & 0xff); \
} \
} \
} while (0)
UNICODE_MAX
#define UNICODE_MAX
Definition: nkf.c:427
VALUE_MASK
#define VALUE_MASK
Definition: nkf.c:425
nkf_char_unicode_bmp_p
#define nkf_char_unicode_bmp_p(c)
Definition: nkf.c:431
NKF_INT32_C
#define NKF_INT32_C(n)
Definition: nkf.h:39

Definition at line 2858 of file nkf.c.

## ◆ OUTPUT_UTF16_BYTES

#define OUTPUT_UTF16_BYTES | ( |  | c1,
|  |  | c2
| ) |  |

Value:
do { \
if (output_endian == ENDIAN_LITTLE){ \
(*o_putc)(c1); \
(*o_putc)(c2); \
}else{ \
(*o_putc)(c2); \
(*o_putc)(c1); \
} \
} while (0)
ENDIAN_LITTLE
@ ENDIAN_LITTLE
Definition: nkf.c:63

Definition at line 2848 of file nkf.c.

## ◆ OUTPUT_UTF32

#define OUTPUT_UTF32 | ( |  | c | ) |

Value:
do { \
if (output_endian == ENDIAN_LITTLE){ \
(*o_putc)( (c) & 0xFF); \
(*o_putc)(((c) >> 8) & 0xFF); \
(*o_putc)(((c) >> 16) & 0xFF); \
(*o_putc)(0); \
}else{ \
(*o_putc)(0); \
(*o_putc)(((c) >> 16) & 0xFF); \
(*o_putc)(((c) >> 8) & 0xFF); \
(*o_putc)( (c) & 0xFF); \
} \
} while (0)

Definition at line 2902 of file nkf.c.

## ◆ OUTPUT_UTF8

#define OUTPUT_UTF8 | ( |  | val | ) |

Value:
do { \
nkf_unicode_to_utf8(val, &c1, &c2, &c3, &c4); \
(*o_putc)(c1); \
if (c2) (*o_putc)(c2); \
if (c3) (*o_putc)(c3); \
if (c4) (*o_putc)(c4); \
} while (0)

Definition at line 2803 of file nkf.c.

## ◆ PREFIX_EUCG3

#define PREFIX_EUCG3 NKF_INT32_C(0x8F00)

Definition at line 422 of file nkf.c.

## ◆ RANGE_NUM_MAX

#define RANGE_NUM_MAX 18

## ◆ rot13

#define rot13 | ( |  | c | ) |

Value:
( \
( c < 'A') ? c: \
(c <= 'M') ? (c + 13): \
(c <= 'Z') ? (c - 13): \
(c < 'a') ? (c): \
(c <= 'm') ? (c + 13): \
(c <= 'z') ? (c - 13): \
(c) \
)

Definition at line 4156 of file nkf.c.

## ◆ rot47

#define rot47 | ( |  | c | ) |

Value:
( \
( c < '!') ? c: \
( c <= 'O') ? (c + 47) : \
( c <= '~') ? (c - 47) : \
c \
)

Definition at line 4166 of file nkf.c.

## ◆ SCORE_CP932

#define SCORE_CP932 (SCORE_DEPEND << 1) /* IBM extended characters */

Definition at line 2959 of file nkf.c.

## ◆ SCORE_DEPEND

#define SCORE_DEPEND (SCORE_KANA << 1) /* MD Characters */

Definition at line 2958 of file nkf.c.

## ◆ SCORE_ERROR

#define SCORE_ERROR (SCORE_iMIME << 1) /* Error */

Definition at line 2964 of file nkf.c.

## ◆ SCORE_iMIME

#define SCORE_iMIME (SCORE_NO_EXIST << 1) /* MIME selected */

Definition at line 2963 of file nkf.c.

## ◆ SCORE_INIT

#define SCORE_INIT (SCORE_iMIME)

Definition at line 2966 of file nkf.c.

## ◆ SCORE_KANA

#define SCORE_KANA (SCORE_L2 << 1) /* Halfwidth Katakana */

Definition at line 2957 of file nkf.c.

## ◆ SCORE_L2

#define SCORE_L2 (1) /* Kanji Level 2 */

Definition at line 2956 of file nkf.c.

## ◆ SCORE_NO_EXIST

#define SCORE_NO_EXIST (SCORE_X0213 << 1) /* Undefined Characters */

Definition at line 2962 of file nkf.c.

## ◆ SCORE_X0212

#define SCORE_X0212 (SCORE_CP932 << 1) /* JIS X 0212 */

Definition at line 2960 of file nkf.c.

## ◆ SCORE_X0213

#define SCORE_X0213 (SCORE_X0212 << 1) /* JIS X 0213 */

Definition at line 2961 of file nkf.c.

## ◆ SEND

#define SEND (void)0 /* output c1 and c2, get next */

Definition at line 5837 of file nkf.c.

## ◆ set_input_mode

#define set_input_mode | ( |  | mode | ) |

Value:
do { \
input_mode = mode; \
shift_mode = 0; \
set_input_codename("ISO-2022-JP"); \
debug("ISO-2022-JP"); \
} while (0)

Definition at line 5839 of file nkf.c.

## ◆ SI

#define SI 0x0f

Definition at line 77 of file nkf.c.

## ◆ SJ0162

#define SJ0162 0x00e1 /* 01 - 62 ku offset */

## ◆ SJ6394

#define SJ6394 0x0161 /* 63 - 94 ku offset */

## ◆ SKIP

#define SKIP c2=0;continue /* no output, get next */

Definition at line 5835 of file nkf.c.

## ◆ SO

#define SO 0x0e

Definition at line 78 of file nkf.c.

## ◆ SP

#define SP 0x20

Definition at line 75 of file nkf.c.

## ◆ SS2

#define SS2 0x8e

Definition at line 79 of file nkf.c.

## ◆ SS3

#define SS3 0x8f

Definition at line 80 of file nkf.c.

## ◆ STD_GC_BUFSIZE

#define STD_GC_BUFSIZE (256)

Definition at line 3321 of file nkf.c.

## ◆ STRICT_MIME

#define STRICT_MIME 8

Definition at line 58 of file nkf.c.

## ◆ TAB

#define TAB 0x09

Definition at line 71 of file nkf.c.

## ◆ UCS_MAP_ASCII

#define UCS_MAP_ASCII 0

Definition at line 347 of file nkf.c.

## ◆ UCS_MAP_CP10001

#define UCS_MAP_CP10001 3

Definition at line 350 of file nkf.c.

## ◆ UCS_MAP_CP932

#define UCS_MAP_CP932 2

Definition at line 349 of file nkf.c.

## ◆ UCS_MAP_MS

#define UCS_MAP_MS 1

Definition at line 348 of file nkf.c.

## ◆ UNICODE_BMP_MAX

#define UNICODE_BMP_MAX NKF_INT32_C(0x0000FFFF)

Definition at line 426 of file nkf.c.

## ◆ UNICODE_MAX

#define UNICODE_MAX NKF_INT32_C(0x0010FFFF)

Definition at line 427 of file nkf.c.

## ◆ UTF16_TO_UTF32

#define UTF16_TO_UTF32 | ( |  | lead,
|  |  | trail
| ) |  | (((lead) << 10) + (trail) - NKF_INT32_C(0x35FDC00))

Definition at line 434 of file nkf.c.

## ◆ VALUE_MASK

#define VALUE_MASK NKF_INT32_C(0x00FFFFFF)

Definition at line 425 of file nkf.c.

## ◆ X0213_SURROGATE_FIND

#define X0213_SURROGATE_FIND | ( |  | tbl,
|  |  | size,
|  |  | euc
| ) |  |

Value:
do { \
int i; \
for (i = 0; i < size; i++) \
if (tbl[i][0] == euc) { \
low = tbl[i][2]; \
break; \
} \
} while (0)
size
voidpf void uLong size
Definition: ioapi.h:138

Definition at line 1976 of file nkf.c.

## Enumeration Type Documentation

## ◆ byte_order

enum byte_order

Enumerator
ENDIAN_BIG |
ENDIAN_LITTLE |
ENDIAN_2143 |
ENDIAN_3412 |

Definition at line 61 of file nkf.c.

## ◆ nkf_encodings

enum nkf_encodings

Enumerator
ASCII |
ISO_8859_1 |
ISO_2022_JP |
CP50220 |
CP50221 |
CP50222 |
ISO_2022_JP_1 |
ISO_2022_JP_3 |
ISO_2022_JP_2004 |
SHIFT_JIS |
WINDOWS_31J |
CP10001 |
EUC_JP |
EUCJP_NKF |
CP51932 |
EUCJP_MS |
EUCJP_ASCII |
SHIFT_JISX0213 |
SHIFT_JIS_2004 |
EUC_JISX0213 |
EUC_JIS_2004 |
UTF_8 |
UTF_8N |
UTF_8_BOM |
UTF8_MAC |
UTF_16 |
UTF_16BE |
UTF_16BE_BOM |
UTF_16LE |
UTF_16LE_BOM |
UTF_32 |
UTF_32BE |
UTF_32BE_BOM |
UTF_32LE |
UTF_32LE_BOM |
BINARY |
NKF_ENCODING_TABLE_SIZE |
JIS_X_0201_1976_K |
JIS_X_0208 |
JIS_X_0212 |
JIS_X_0213_2 |
JIS_X_0213_1 |

Definition at line 86 of file nkf.c.

## Function Documentation

## ◆ main()

int main | ( | int argc | ,
|  | char ** | argv
| ) |  |

Definition at line 6934 of file nkf.c.

References argc, argv, dup2(), FALSE, fileno, IOBUF_SIZE, mktemp, nkf_xfree, NULL, setbinmode, setvbuffer, stat, strlen(), and TRUE.

## Variable Documentation

## ◆ alias

const char* alias

Definition at line 1159 of file nkf.c.

Referenced by Init_psych_emitter(), rb_enc_alias(), rb_encdb_alias(), and yyparse().

## ◆ buf

unsigned char buf[MIMEOUT_BUF_LENGTH+1]

Definition at line 4322 of file nkf.c.

## ◆ count

int count

Definition at line 5055 of file nkf.c.

Referenced by asn1time_to_time(), clock_gettime(), count(), decode(), EVENTSINK_Invoke(), ffi_closure_SYSV(), ffi_prep_args(), ffi_prep_cif_machdep(), inflate_table(), inflate_table9(), Init_Encoding(), main(), nkf_split_options(), olerecord_set_ivar(), rb_ivar_count(), rb_memory_view_parse_item_format(), rb_vm_bugreport(), ruby_malloc_size_overflow(), scan_tree(), send_tree(), and waitpid().

## ◆

struct { ... } encoding_name_to_id_table[]

## ◆ id

const int id

Definition at line 209 of file nkf.c.

Referenced by rb_autoload_str(), rb_const_set(), rb_define_class(), rb_define_module(), rb_deprecate_constant(), rb_execarg_addopt(), rb_f_untrace_var(), rb_id_attrset(), rb_mod_remove_cvar(), rb_obj_remove_instance_variable(), rb_path_to_class(), rb_str_intern(), rb_sym2id(), rb_sym_to_proc(), rsock_ipaddr(), rsock_revlookup_flag(), ruby_debug_print_id(), and yyparse().

## ◆ input

unsigned int input

Definition at line 4325 of file nkf.c.

Referenced by deflate_index_build(), deflate_index_extract(), and rb_parser_compile_generic().

## ◆ input_code_list

struct input_code input_code_list[]

Initial value:
= {
{"EUC-JP", 0, 0, 0, {0, 0, 0}, e_status, e_iconv, 0},
{"Shift_JIS", 0, 0, 0, {0, 0, 0}, s_status, s_iconv, 0},
{"UTF-8", 0, 0, 0, {0, 0, 0}, w_status, w_iconv, 0},
{"UTF-16", 0, 0, 0, {0, 0, 0}, NULL, w_iconv16, 0},
{"UTF-32", 0, 0, 0, {0, 0, 0}, NULL, w_iconv32, 0},
{NULL, 0, 0, 0, {0, 0, 0}, NULL, NULL, 0}
}
NULL
#define NULL
Definition: regenc.h:69

Definition at line 475 of file nkf.c.

## ◆ last

unsigned int last

Definition at line 4324 of file nkf.c.

Referenced by _tr_flush_block(), _tr_stored_block(), deflate_index_build(), deflate_stored(), doit(), gunpipe(), gzcopy(), gzip_normalize(), gztack(), inflate(), inflate_fast(), inflateBack(), inflateBack9(), log_last(), lunpipe(), puff(), rb_enc_path_last_separator(), rotate(), ruby_enc_find_extname(), and sip_hash13().

## ◆ mime_priority_func

nkf_char(* mime_priority_func[])(nkf_char c2, nkf_char c1, nkf_char c0) | ( | nkf_char | c2,
|  | nkf_char | c1,
|  | nkf_char | c0
| ) |  |

Initial value:
= {
e_iconv, s_iconv, 0, 0, 0, 0, 0,
w_iconv, w_iconv,
0,
}

Definition at line 4289 of file nkf.c.

## ◆ name

const char* name

Definition at line 208 of file nkf.c.

Referenced by bopen(), create_win32ole_method(), create_win32ole_param(), create_win32ole_type(), create_win32ole_variable(), getifaddrs(), GetX509NamePtr(), gzcopy(), gzscan(), gztack(), Init_ossl_asn1(), izstream::izstream(), load(), main(), ole_docinfo_from_type(), onig_name_to_backref_number(), onig_name_to_group_numbers(), izstream::open(), ozstream::open(), ossl_evp_get_digestbyname(), ossl_x509name_new(), ozstream::ozstream(), rb_assert_failure(), rb_builtin_type_name(), rb_check_id(), rb_check_id_cstr(), rb_check_symbol(), rb_check_symbol_cstr(), rb_check_typeddata(), rb_const_missing(), rb_cv_get(), rb_cv_set(), rb_define_attr(), rb_define_class(), rb_define_class_under(), rb_define_class_variable(), rb_define_const(), rb_define_dummy_encoding(), rb_define_global_const(), rb_define_global_function(), rb_define_hooked_variable(), rb_define_method(), rb_define_module(), rb_define_module_function(), rb_define_module_under(), rb_define_private_method(), rb_define_protected_method(), rb_define_readonly_variable(), rb_define_singleton_method(), rb_define_variable(), rb_define_virtual_variable(), rb_deprecate_constant(), rb_dtrace_setup(), rb_enc_find(), rb_enc_find_index(), rb_enc_find_index2(), rb_enc_register(), rb_enc_replicate(), rb_enc_set_base(), rb_enc_symname2_p(), rb_enc_symname_p(), rb_enc_symname_type(), rb_encdb_declare(), rb_encdb_dummy(), rb_encdb_replicate(), rb_file_const(), rb_file_dirname(), rb_freopen(), rb_gv_get(), rb_gv_set(), rb_gvar_ractor_local(), rb_intern(), rb_intern2(), rb_intern3(), rb_is_class_name(), rb_is_const_name(), rb_is_instance_name(), rb_is_local_name(), rb_iseq_new(), rb_iseq_new_eval(), rb_iseq_new_top(), rb_iseq_new_with_callback(), rb_iseq_new_with_opt(), rb_iv_get(), rb_iv_set(), rb_make_no_method_exception(), rb_method_for_self_aref(), rb_method_for_self_aset(), rb_mod_const_missing(), rb_mod_remove_const(), rb_mod_remove_cvar(), rb_nkf_enc_get(), rb_obj_remove_instance_variable(), rb_parser_show_bitstack(), rb_print_undef_str(), rb_ractor_ensure_shareable(), rb_reg_regsub(), rb_remove_method(), rb_set_class_path(), rb_set_class_path_string(), rb_setup_fake_str(), rb_struct_define(), rb_struct_define_under(), rb_sym_intern(), rb_symname_p(), rb_to_encoding_index(), rb_to_id(), rb_to_symbol(), rb_undef_method(), rb_vm_bugreport(), rb_w32_getenv(), rb_w32_gethostbyname(), rb_w32_gethostname(), rb_w32_getprotobyname(), rb_w32_getservbyname(), rb_w32_pipe(), rb_w32_read_reparse_point(), rb_w32_set_thread_description(), rb_w32_set_thread_description_str(), rb_w32_ugetenv(), reg_open_key(), rsock_intern_family(), rsock_intern_family_noprefix(), rsock_intern_ip_optname(), rsock_intern_iplevel(), rsock_intern_ipproto(), rsock_intern_ipv6_optname(), rsock_intern_local_optname(), rsock_intern_protocol_family(), rsock_intern_scm_optname(), rsock_intern_so_optname(), rsock_intern_socktype(), rsock_intern_tcp_optname(), rsock_intern_udp_optname(), ruby_enc_find_basename(), ruby_enc_find_extname(), ruby_getpeername(), ruby_getsockname(), ruby_init_ext(), ruby_script(), ruby_set_script_name(), ruby_setenv(), and ruby_unsetenv().

## ◆ nkf_encoding_table

nkf_encoding nkf_encoding_table[]

Definition at line 167 of file nkf.c.

## ◆ NkfEncodingASCII

nkf_native_encoding NkfEncodingASCII = { "ASCII", e_iconv, e_oconv }

Definition at line 153 of file nkf.c.

## ◆ NkfEncodingEUC_JP

nkf_native_encoding NkfEncodingEUC_JP = { "EUC-JP", e_iconv, e_oconv }

Definition at line 156 of file nkf.c.

## ◆ NkfEncodingISO_2022_JP

nkf_native_encoding NkfEncodingISO_2022_JP = { "ISO-2022-JP", e_iconv, j_oconv }

Definition at line 154 of file nkf.c.

## ◆ NkfEncodingShift_JIS

nkf_native_encoding NkfEncodingShift_JIS = { "Shift_JIS", s_iconv, s_oconv }

Definition at line 155 of file nkf.c.

## ◆ NkfEncodingUTF_16

nkf_native_encoding NkfEncodingUTF_16 = { "UTF-16", w_iconv16, w_oconv16 }

Definition at line 158 of file nkf.c.

## ◆ NkfEncodingUTF_32

nkf_native_encoding NkfEncodingUTF_32 = { "UTF-32", w_iconv32, w_oconv32 }

Definition at line 159 of file nkf.c.

## ◆ NkfEncodingUTF_8

nkf_native_encoding NkfEncodingUTF_8 = { "UTF-8", w_iconv, w_oconv }

Definition at line 157 of file nkf.c.

## ◆ top

unsigned int top

Definition at line 4323 of file nkf.c.

Referenced by __attribute__(), getaddrinfo(), rb_ary_shift(), rb_file_dirname(), and ruby_qsort().