Ruby  2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
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 {
enum  {
  RUBY_FMODE_READABLE = FMODE_READABLE, RUBY_FMODE_WRITABLE = FMODE_WRITABLE, RUBY_FMODE_READWRITE = FMODE_READWRITE, RUBY_FMODE_BINMODE = FMODE_BINMODE,
  RUBY_FMODE_SYNC = FMODE_SYNC, RUBY_FMODE_TTY = FMODE_TTY, RUBY_FMODE_DUPLEX = FMODE_DUPLEX, RUBY_FMODE_APPEND = FMODE_APPEND,
  RUBY_FMODE_CREATE = FMODE_CREATE, RUBY_FMODE_NOREVLOOKUP = 0x00000100, RUBY_FMODE_TRUNC = FMODE_TRUNC, RUBY_FMODE_TEXTMODE = FMODE_TEXTMODE,
  RUBY_FMODE_PREP = 0x00010000, RUBY_FMODE_SETENC_BY_BOM = FMODE_SETENC_BY_BOM, RUBY_FMODE_UNIX = 0x00200000, RUBY_FMODE_INET = 0x00400000,
  RUBY_FMODE_INET6 = 0x00800000, RUBY_NODE_TYPESHIFT = NODE_TYPESHIFT, RUBY_NODE_TYPEMASK = NODE_TYPEMASK, RUBY_NODE_LSHIFT = NODE_LSHIFT,
  RUBY_NODE_FL_NEWLINE = NODE_FL_NEWLINE
}
 
   enum ruby_special_consts   special_consts
 
   enum ruby_value_type   value_type
 
   enum ruby_tag_type   tag_type
 
   enum node_type   node_type
 
   enum ruby_method_ids   method_ids
 
   enum ruby_id_types   id_types
 
   enum ruby_fl_type   fl_types
 
   enum ruby_encoding_consts   encoding_consts
 
   enum ruby_coderange_type   enc_coderange_types
 
   enum ruby_econv_flag_type   econv_flag_types
 
   enum ruby_robject_flags   robject_flags
 
   enum ruby_rmodule_flags   rmodule_flags
 
   enum ruby_rstring_flags   rstring_flags
 
   enum ruby_rarray_flags   rarray_flags
 
   enum { ... }    various
 
   union {
enum  { RUBY_IMEMO_MASK = IMEMO_MASK }
 
      enum imemo_type   types
 
      enum { ... } ::   mask
 
      struct RIMemo *   ptr
 
   }   imemo
 
   struct RSymbol *   symbol_ptr
 
   enum vm_call_flag_bits   vm_call_flags
 
   struct rb_encoding_entry *   list
 
   int   count
 
   int   size
 
   st_table *   names
 
   uint8_t   len
 
   char   str [HTML_ESCAPE_MAX_LEN+1]
 
   const char *   name
 
   const int   id
 
   int   nid
 
   ID   id_BEGIN
 
   ID   id_END
 
   ID   id_alias
 
   ID   id_alias_error
 
   ID   id_aref
 
   ID   id_aref_field
 
   ID   id_arg_ambiguous
 
   ID   id_arg_paren
 
   ID   id_args_add
 
   ID   id_args_add_block
 
   ID   id_args_add_star
 
   ID   id_args_forward
 
   ID   id_args_new
 
   ID   id_array
 
   ID   id_aryptn
 
   ID   id_assign
 
   ID   id_assign_error
 
   ID   id_assoc_new
 
   ID   id_assoc_splat
 
   ID   id_assoclist_from_args
 
   ID   id_bare_assoc_hash
 
   ID   id_begin
 
   ID   id_binary
 
   ID   id_block_var
 
   ID   id_blockarg
 
   ID   id_bodystmt
 
   ID   id_brace_block
 
   ID   id_break
 
   ID   id_call
 
   ID   id_case
 
   ID   id_class
 
   ID   id_class_name_error
 
   ID   id_command
 
   ID   id_command_call
 
   ID   id_const_path_field
 
   ID   id_const_path_ref
 
   ID   id_const_ref
 
   ID   id_def
 
   ID   id_defined
 
   ID   id_defs
 
   ID   id_do_block
 
   ID   id_dot2
 
   ID   id_dot3
 
   ID   id_dyna_symbol
 
   ID   id_else
 
   ID   id_elsif
 
   ID   id_ensure
 
   ID   id_excessed_comma
 
   ID   id_fcall
 
   ID   id_field
 
   ID   id_for
 
   ID   id_hash
 
   ID   id_heredoc_dedent
 
   ID   id_hshptn
 
   ID   id_if
 
   ID   id_if_mod
 
   ID   id_ifop
 
   ID   id_in
 
   ID   id_kwrest_param
 
   ID   id_lambda
 
   ID   id_magic_comment
 
   ID   id_massign
 
   ID   id_method_add_arg
 
   ID   id_method_add_block
 
   ID   id_mlhs_add
 
   ID   id_mlhs_add_post
 
   ID   id_mlhs_add_star
 
   ID   id_mlhs_new
 
   ID   id_mlhs_paren
 
   ID   id_module
 
   ID   id_mrhs_add
 
   ID   id_mrhs_add_star
 
   ID   id_mrhs_new
 
   ID   id_mrhs_new_from_args
 
   ID   id_next
 
   ID   id_nokw_param
 
   ID   id_opassign
 
   ID   id_operator_ambiguous
 
   ID   id_param_error
 
   ID   id_params
 
   ID   id_paren
 
   ID   id_parse_error
 
   ID   id_program
 
   ID   id_qsymbols_add
 
   ID   id_qsymbols_new
 
   ID   id_qwords_add
 
   ID   id_qwords_new
 
   ID   id_redo
 
   ID   id_regexp_add
 
   ID   id_regexp_literal
 
   ID   id_regexp_new
 
   ID   id_rescue
 
   ID   id_rescue_mod
 
   ID   id_rest_param
 
   ID   id_retry
 
   ID   id_return
 
   ID   id_return0
 
   ID   id_sclass
 
   ID   id_stmts_add
 
   ID   id_stmts_new
 
   ID   id_string_add
 
   ID   id_string_concat
 
   ID   id_string_content
 
   ID   id_string_dvar
 
   ID   id_string_embexpr
 
   ID   id_string_literal
 
   ID   id_super
 
   ID   id_symbol
 
   ID   id_symbol_literal
 
   ID   id_symbols_add
 
   ID   id_symbols_new
 
   ID   id_top_const_field
 
   ID   id_top_const_ref
 
   ID   id_unary
 
   ID   id_undef
 
   ID   id_unless
 
   ID   id_unless_mod
 
   ID   id_until
 
   ID   id_until_mod
 
   ID   id_var_alias
 
   ID   id_var_field
 
   ID   id_var_ref
 
   ID   id_vcall
 
   ID   id_void_stmt
 
   ID   id_when
 
   ID   id_while
 
   ID   id_while_mod
 
   ID   id_word_add
 
   ID   id_word_new
 
   ID   id_words_add
 
   ID   id_words_new
 
   ID   id_xstring_add
 
   ID   id_xstring_literal
 
   ID   id_xstring_new
 
   ID   id_yield
 
   ID   id_yield0
 
   ID   id_zsuper
 
   unsigned short   token
 
   const char   name [3]
 
   const char   term
 
   seed_keys_t   key
 
   uint32_t   u32 [type_roomof(seed_keys_t,
      uint32_t)]
 
   char   bin [32]
 
   uint64_t   u64 [4]
 
   unsigned int   size
 
   unsigned int   mask
 
   struct cache_entry *   entries
 
   DWORD   winerr
 
   int   err
 
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)

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)

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)

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)))

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)

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)

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)

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)

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

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 NULL.

Variable Documentation

◆ alias

const char* alias

Definition at line 1159 of file nkf.c.

◆ buf

◆ count

int count

Definition at line 5055 of file nkf.c.

Referenced by nkf_split_options().

◆ encoding_name_to_id_table

struct { ... } encoding_name_to_id_table[]

◆ id

const int id

◆ input

unsigned int input

Definition at line 4325 of file nkf.c.

◆ 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}
}

Definition at line 473 of file nkf.c.

◆ last

unsigned int last

Definition at line 4324 of file nkf.c.

Referenced by doit(), rb_enc_path_last_separator(), ruby_enc_find_extname(), and sip_hash13().

◆ mime_priority_func

nkf_char(* mime_priority_func[])(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 GetX509NamePtr(), ole_docinfo_from_type(), onig_name_to_backref_number(), ossl_evp_get_digestbyname(), ossl_x509name_new(), rb_assert_failure(), rb_builtin_type_name(), rb_check_id(), rb_check_id_cstr(), rb_check_symbol(), rb_check_symbol_cstr(), rb_const_missing(), rb_define_attr(), rb_define_class(), rb_define_class_under(), rb_define_const(), rb_define_dummy_encoding(), rb_define_global_const(), rb_define_global_function(), 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_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_registered(), rb_enc_set_base(), rb_enc_symname2_p(), rb_enc_symname_p(), rb_enc_symname_type(), rb_encdb_declare(), rb_encdb_replicate(), rb_file_dirname(), rb_freopen(), rb_intern(), rb_intern2(), rb_intern3(), rb_iseq_new(), rb_iseq_new_top(), rb_iv_get(), rb_iv_set(), rb_make_no_method_exception(), 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_reg_regsub(), rb_set_class_path(), rb_struct_define(), rb_struct_define_under(), rb_sym_intern(), rb_symname_p(), rb_to_id(), rb_to_symbol(), rb_undef_method(), rb_vm_bugreport(), rb_w32_gethostbyname(), rb_w32_gethostname(), rb_w32_getprotobyname(), rb_w32_getservbyname(), rb_w32_pipe(), 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_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

Definition at line 4323 of file nkf.c.

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

ASCII
@ ASCII
Definition: nkf.c:87
DEL
#define DEL
Definition: nkf.c:76
i
uint32_t i
Definition: rb_mjit_min_header-2.7.2.h:5499
NkfEncodingUTF_32
nkf_native_encoding NkfEncodingUTF_32
Definition: nkf.c:159
NULL
#define NULL
Definition: _sdbm.c:101
CP50221
@ CP50221
Definition: nkf.c:91
LF
#define LF
Definition: nkf.c:72
NKF_INT32_C
#define NKF_INT32_C(n)
Definition: nkf.h:39
nkf_char_unicode_bmp_p
#define nkf_char_unicode_bmp_p(c)
Definition: nkf.c:431
VALUE_MASK
#define VALUE_MASK
Definition: nkf.c:425
NkfEncodingISO_2022_JP
nkf_native_encoding NkfEncodingISO_2022_JP
Definition: nkf.c:154
CP50220
@ CP50220
Definition: nkf.c:90
UNICODE_MAX
#define UNICODE_MAX
Definition: nkf.c:427
size
int size
Definition: encoding.c:58
CR
#define CR
Definition: nkf.c:73
ENDIAN_LITTLE
@ ENDIAN_LITTLE
Definition: nkf.c:63
NkfEncodingUTF_16
nkf_native_encoding NkfEncodingUTF_16
Definition: nkf.c:158
ESC
#define ESC
Definition: nkf.c:74
CP50222
@ CP50222
Definition: nkf.c:92
ISO_8859_1
@ ISO_8859_1
Definition: nkf.c:88
NkfEncodingUTF_8
nkf_native_encoding NkfEncodingUTF_8
Definition: nkf.c:157
SP
#define SP
Definition: nkf.c:75
NkfEncodingASCII
nkf_native_encoding NkfEncodingASCII
Definition: nkf.c:153