1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/nkf/nkf.c ext/nkf/lib/kconv.rb: Add rdoc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2006-02-23 23:17:20 +00:00
parent e7d3da866b
commit 2507e957e0
2 changed files with 562 additions and 119 deletions

View file

@ -1,82 +1,65 @@
#
# kconv.rb - Kanji Converter.
#
# $Id$
#
require 'nkf'
module Kconv
#
# Public Constants
#
#Constant of Encoding
AUTO = ::NKF::AUTO
JIS = ::NKF::JIS
EUC = ::NKF::EUC
SJIS = ::NKF::SJIS
BINARY = ::NKF::BINARY
NOCONV = ::NKF::NOCONV
ASCII = ::NKF::ASCII
UTF8 = ::NKF::UTF8
UTF16 = ::NKF::UTF16
UTF32 = ::NKF::UTF32
UNKNOWN = ::NKF::UNKNOWN
# Auto-Detect
AUTO = NKF::AUTO
# ISO-2022-JP
JIS = NKF::JIS
# EUC-JP
EUC = NKF::EUC
# Shift_JIS
SJIS = NKF::SJIS
# BINARY
BINARY = NKF::BINARY
# NOCONV
NOCONV = NKF::NOCONV
# ASCII
ASCII = NKF::ASCII
# UTF-8
UTF8 = NKF::UTF8
# UTF-16
UTF16 = NKF::UTF16
# UTF-32
UTF32 = NKF::UTF32
# UNKNOWN
UNKNOWN = NKF::UNKNOWN
#
# Private Constants
#
# Revision of kconv.rb
REVISION = %q$Revision$
#Regexp of Encoding
Iconv_Shift_JIS = /\A(?:
[\x00-\x7f\xa1-\xdf] |
\x81[\x40-\x7e\x80-\xac\xb8-\xbf\xc8-\xce\xda-\xe8\xf0-\xf7\xfc] |
\x82[\x4f-\x58\x60-\x79\x81-\x9a\x9f-\xf1] |
\x83[\x40-\x7e\x80-\x96\x9f-\xb6\xbf-\xd6\x40-\x60] |
\x84[\x40-\x60\x70-\x7e\x80-\x91\x9f-\xbe\x9f-\xfc] |
[\x89-\x8f\x90-\x97\x99-\x9f\xe0-\xea][\x40-\x7e] |
[\x89-\x97\x99-\x9f\xe0-\xe9][\x80-\xfc] |
\x98[\x40-\x72\x9f-\xfc] |
\xea[\x80-\xa4]
)*\z/nx
Iconv_EUC_JP = /\A(?:
[\x00-\x7f] |
\x8e [\xa1-\xdf] |
\x8f [\xa1-\xdf] [\xa1-\xdf] |
[\xa1\xb0-\xbce\xd0-\xf3][\xa1-\xfe] |
\xa2[\xa1-\xae\xba-\xc1\xca-\xd0\xdc-\xea\xf2-\xf9\xfe] |
\xa3[\xb0-\xb9\xc1-\xda\xe1-\xfa] |
\xa4[\xa1-\xf3] |
\xa5[\xa1-\xf6] |
\xa6[\xa1-\xb8\xc1-\xd8] |
\xa7[\xa1-\xc1\xd1-\xf1] |
\xa8[\xa1-\xc0] |
\xcf[\xa1-\xd3] |
\xf4[\xa1-\xa6]
)*\z/nx
Iconv_UTF8 = /\A(?:\xef\xbb\xbf)?(?:
[\x00-\x7f] |
\xc2[\x80-\x8d\x90-\x9f\xa1\xaa\xac\xae-\xb1\xb4\xb6\xb8\xba\xbf] |
\xc3[\x80-\xbf] |
\xc4[\x80-\x93\x96-\xa2\xa4-\xab\xae-\xbf] |
\xc5[\x80-\x8d\x90-\xbe] |
\xc7[\x8d-\x9c\xb5] |
\xcb[\x87\x98-\x9b\x9d] |
\xce[\x84-\x86\x88-\x8a\x8c\x8e-\xa1\xa3-\xbf] |
\xcf[\x80-\x8e] |
\xd0[\x81-\x8c\x8e-\xbf] |
\xd1[\x80-\x8f\x91-\x9f] |
\xe2\x84[\x83\x96\xa2\xab] |
\xe2\x86[\x83\x91-\x93\x96\xa2\xab] |
\xe2\x87[\x83\x91-\x94\x96\xa2\xab] |
\xe2\x88[\x82-\x83\x87-\x88\x8b\x91-\x94\x96\x9a\x9d-\x9e\xa0\xa2\xa7-\xac\xb4-\xb5\xbd] |
\xe2\x89[\x82-\x83\x87-\x88\x8b\x91-\x94\x96\x9a\x9d-\x9e\xa0-\xa2\xa6-\xac\xb4-\xb5\xbd] |
\xe2[\x8a\x8c][\x82-\x83\x86-\x88\x8b\x91-\x94\x96\x9a\x9d-\x9e\xa0-\xa2\xa5-\xac\xb4-\xb5\xbd] |
\xe2[\x94-\x99][\x81-\x83\x86-\x88\x8b-\x8c\x8f-\x94\x96-\x98\x9a-\x9e\xa0-\xac\xaf-\xb0\xb3-\xb5\xb7-\xb8\xbb-\xbd\xbf] |
\xe3\x80[\x81-\x83\x85-\x98\x9a-\x9e\xa0-\xad\xaf-\xb0\xb2-\xb5\xb7-\xb8\xbb-\xbd\xbf] |
\xe3[\x81-\x83\xb8-\xbf][\x81-\xbf] |
[\xe5-\xe7][\x80-\xbf][\x81-\xbf] |
\xe8[\x80-\xae\xb0-\xbf][\x81-\xbf] |
\xe9[\x80-\x92\x95-\xb1\xb3-\xbe][\x81-\xbf] |
\xef[\xbc-\xbe][\x81-\xbf] |
)*\z/nx
# Regexp of Shift_JIS string (private constant)
RegexpShiftjis = /\A(?:
[\x00-\x7f\xa1-\xdf] |
[\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc]
)*\z/nx
# Regexp of EUC-JP string (private constant)
RegexpEucjp = /\A(?:
[\x00-\x7f] |
\x8e [\xa1-\xdf] |
\x8f [\xa1-\xdf] [\xa1-\xfe] |
[\xa1-\xdf] [\xa1-\xfe]
)*\z/nx
# Regexp of UTF-8 string (private constant)
RegexpUtf8 = /\A(?:
[\x00-\x7f] |
[\xc2-\xdf] [\x80-\xbf] |
@ -88,9 +71,19 @@ module Kconv
)*\z/nx
#
# kconv
# Public Methods
#
# call-seq:
# Kconv.kconv(str, out_code, in_code = Kconv::AUTO)
#
# Convert <code>str</code> to out_code.
# <code>out_code</code> and <code>in_code</code> are given as constants of Kconv.
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want to decode them, use NKF.nkf.
def kconv(str, out_code, in_code = AUTO)
opt = '-'
case in_code
@ -131,26 +124,71 @@ module Kconv
# Encode to
#
# call-seq:
# Kconv.tojis(str) -> string
#
# Convert <code>str</code> to ISO-2022-JP
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-jxm0', str).
def tojis(str)
::NKF::nkf('-j', str)
end
module_function :tojis
# call-seq:
# Kconv.toeuc(str) -> string
#
# Convert <code>str</code> to EUC-JP
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-exm0', str).
def toeuc(str)
::NKF::nkf('-e', str)
end
module_function :toeuc
# call-seq:
# Kconv.tosjis(str) -> string
#
# Convert <code>str</code> to Shift_JIS
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-sxm0', str).
def tosjis(str)
::NKF::nkf('-s', str)
end
module_function :tosjis
# call-seq:
# Kconv.toutf8(str) -> string
#
# Convert <code>str</code> to UTF-8
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-wxm0', str).
def toutf8(str)
::NKF::nkf('-w', str)
end
module_function :toutf8
# call-seq:
# Kconv.toutf16(str) -> string
#
# Convert <code>str</code> to UTF-16
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-w16xm0', str).
def toutf16(str)
::NKF::nkf('-w16', str)
end
@ -160,11 +198,19 @@ module Kconv
# guess
#
# call-seq:
# Kconv.guess(str) -> integer
#
# Guess input encoding by NKF.guess2
def guess(str)
::NKF::guess(str)
end
module_function :guess
# call-seq:
# Kconv.guess_old(str) -> integer
#
# Guess input encoding by NKF.guess1
def guess_old(str)
::NKF::guess1(str)
end
@ -174,16 +220,34 @@ module Kconv
# isEncoding
#
# call-seq:
# Kconv.iseuc(str) -> obj or nil
#
# Returns whether input encoding is EUC-JP or not.
#
# *Note* don't expect this return value is MatchData.
def iseuc(str)
RegexpEucjp.match( str )
end
module_function :iseuc
# call-seq:
# Kconv.issjis(str) -> obj or nil
#
# Returns whether input encoding is Shift_JIS or not.
#
# *Note* don't expect this return value is MatchData.
def issjis(str)
RegexpShiftjis.match( str )
end
module_function :issjis
# call-seq:
# Kconv.isutf8(str) -> obj or nil
#
# Returns whether input encoding is UTF-8 or not.
#
# *Note* don't expect this return value is MatchData.
def isutf8(str)
RegexpUtf8.match( str )
end
@ -192,37 +256,104 @@ module Kconv
end
class String
# call-seq:
# String#kconv(out_code, in_code = Kconv::AUTO)
#
# Convert <code>self</code> to out_code.
# <code>out_code</code> and <code>in_code</code> are given as constants of Kconv.
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want to decode them, use NKF.nkf.
def kconv(out_code, in_code=Kconv::AUTO)
Kconv::kconv(self, out_code, in_code)
end
#
# to Encoding
def tojis
::NKF::nkf('-j', self)
end
def toeuc
::NKF::nkf('-e', self)
end
def tosjis
::NKF::nkf('-s', self)
end
def toutf8
::NKF::nkf('-w', self)
end
def toutf16
::NKF::nkf('-w16', self)
end
#
# call-seq:
# String#tojis -> string
#
# Convert <code>self</code> to ISO-2022-JP
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-jxm0', str).
def tojis; Kconv.tojis(self) end
# call-seq:
# String#toeuc -> string
#
# Convert <code>self</code> to EUC-JP
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-exm0', str).
def toeuc; Kconv.toeuc(self) end
# call-seq:
# String#tosjis -> string
#
# Convert <code>self</code> to Shift_JIS
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-sxm0', str).
def tosjis; Kconv.tosjis(self) end
# call-seq:
# String#toutf8 -> string
#
# Convert <code>self</code> to UTF-8
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-wxm0', str).
def toutf8; Kconv.toutf8(self) end
# call-seq:
# String#toutf16 -> string
#
# Convert <code>self</code> to UTF-16
#
# *Note*
# This method decode MIME encoded string and
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-w16xm0', str).
def toutf16; Kconv.toutf16(self) end
#
# is Encoding
def iseuc
Kconv.iseuc( self )
end
#
def issjis
Kconv.issjis( self )
end
# call-seq:
# String#iseuc -> obj or nil
#
# Returns whether <code>self</code>'s encoding is EUC-JP or not.
#
# *Note* don't expect this return value is MatchData.
def iseuc; Kconv.iseuc(self) end
def isutf8
Kconv.isutf8( self )
end
# call-seq:
# String#issjis -> obj or nil
#
# Returns whether <code>self</code>'s encoding is Shift_JIS or not.
#
# *Note* don't expect this return value is MatchData.
def issjis; Kconv.issjis(self) end
# call-seq:
# String#isutf8 -> obj or nil
#
# Returns whether <code>self</code>'s encoding is UTF-8 or not.
#
# *Note* don't expect this return value is MatchData.
def isutf8; Kconv.isutf8(self) end
end

View file

@ -1,9 +1,9 @@
/*
* NKF Module for Ruby base on nkf 2.x
* NKF - Ruby extension for Network Kanji Filter
*
* original nkf2.x is maintained at http://sourceforge.jp/projects/nkf/
* original nkf2.x is maintained at http://sourceforge.jp/projects/nkf/
*
* $Id$
* $Id$
*
*/
@ -78,6 +78,21 @@ rb_nkf_putchar(c)
#include "nkf-utf8/utf8tbl.c"
#include "nkf-utf8/nkf.c"
/*
* call-seq:
* NKF.nkf(opt, str) -> string
*
* Convert _str_ and return converted result.
* Conversion details are specified by _opt_ as String.
*
* require 'nkf'
* output = NKF.nkf("-s", input)
*
* *Note*
* By default, nkf decodes MIME encoded string.
* If you want not to decode input, use NKF.nkf with <b>-m0</b> flag.
*/
static VALUE
rb_nkf_kconv(obj, opt, src)
VALUE obj, opt, src;
@ -118,11 +133,27 @@ rb_nkf_kconv(obj, opt, src)
/*
* NKF.guess1
* call-seq:
* NKF.guess1(str) -> integer
*
* Character code detection - Algorithm described in:
* Ken Lunde. `Understanding Japanese Information Processing'
* Sebastopol, CA: O'Reilly & Associates.
* Returns guessed encoding of _str_ as integer.
*
* Algorithm described in:
* Ken Lunde. `Understanding Japanese Information Processing'
* Sebastopol, CA: O'Reilly & Associates.
*
* case NKF.guess1(input)
* when NKF::JIS
* "ISO-2022-JP"
* when NKF::SJIS
* "Shift_JIS"
* when NKF::EUC
* "EUC-JP"
* when NKF::UNKNOWN
* "UNKNOWN(ASCII)"
* when NKF::BINARY
* "BINARY"
* end
*/
static VALUE
@ -214,9 +245,29 @@ rb_nkf_guess1(obj, src)
/*
* NKF.guess2
* call-seq:
* NKF.guess2(str) -> integer
*
* Guess Encoding By NKF2.0 Routine
* Returns guessed encoding of _str_ as integer by nkf routine.
*
* case NKF.guess(input)
* when NKF::ASCII
* "ASCII"
* when NKF::JIS
* "ISO-2022-JP"
* when NKF::SJIS
* "Shift_JIS"
* when NKF::EUC
* "EUC-JP"
* when NKF::UTF8
* "UTF-8"
* when NKF::UTF16
* "UTF-16"
* when NKF::UNKNOWN
* "UNKNOWN"
* when NKF::BINARY
* "BINARY"
* end
*/
static VALUE
@ -261,32 +312,293 @@ rb_nkf_guess2(obj, src)
}
/* Initialize NKF Module */
/*
* NKF - Ruby extension for Network Kanji Filter
*
* == Description
*
* This is a Ruby Extension version of nkf (Netowrk Kanji Filter).
* It converts the first argument and return converted result. Conversion
* details are specified by flags as the first argument.
*
* *Nkf* is a yet another kanji code converter among networks, hosts and terminals.
* It converts input kanji code to designated kanji code
* such as ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 or UTF-16.
*
* One of the most unique faculty of *nkf* is the guess of the input kanji encodings.
* It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 and UTF-16.
* So users needn't set the input kanji code explicitly.
*
* By default, X0201 kana is converted into X0208 kana.
* For X0201 kana, SO/SI, SSO and ESC-(-I methods are supported.
* For automatic code detection, nkf assumes no X0201 kana in Shift_JIS.
* To accept X0201 in Shift_JIS, use <b>-X</b>, <b>-x</b> or <b>-S</b>.
*
* == Flags
*
* === -b -u
*
* Output is buffered (DEFAULT), Output is unbuffered.
*
* === -j -s -e -w -w16
*
* Output code is ISO-2022-JP (7bit JIS), Shift_JIS, EUC-JP,
* UTF-8N, UTF-16BE.
* Without this option and compile option, ISO-2022-JP is assumed.
*
* === -J -S -E -W -W16
*
* Input assumption is JIS 7 bit, Shift_JIS, EUC-JP,
* UTF-8, UTF-16LE.
*
* ==== -J
*
* Assume JIS input. It also accepts EUC-JP.
* This is the default. This flag does not exclude Shift_JIS.
*
* ==== -S
*
* Assume Shift_JIS and X0201 kana input. It also accepts JIS.
* EUC-JP is recognized as X0201 kana. Without <b>-x</b> flag,
* X0201 kana (halfwidth kana) is converted into X0208.
*
* ==== -E
*
* Assume EUC-JP input. It also accepts JIS.
* Same as -J.
*
* === -t
*
* No conversion.
*
* === -i_
*
* Output sequence to designate JIS-kanji. (DEFAULT B)
*
* === -o_
*
* Output sequence to designate ASCII. (DEFAULT B)
*
* === -r
*
* {de/en}crypt ROT13/47
*
* === -h[123] --hiragana --katakana --katakana-hiragana
*
* [-h1 --hiragana] Katakana to Hiragana conversion.
*
* [-h2 --katakana] Hiragana to Katakana conversion.
*
* [-h3 --katakana-hiragana] Katakana to Hiragana and Hiragana to Katakana conversion.
*
* === -T
*
* Text mode output (MS-DOS)
*
* === -l
*
* ISO8859-1 (Latin-1) support
*
* === -f[<code>m</code> [- <code>n</code>]]
*
* Folding on <code>m</code> length with <code>n</code> margin in a line.
* Without this option, fold length is 60 and fold margin is 10.
*
* === -F
*
* New line preserving line folding.
*
* === -Z[0-3]
*
* Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
*
* [-Z -Z0] Convert X0208 alphabet to ASCII.
*
* [-Z1] Converts X0208 kankaku to single ASCII space.
*
* [-Z2] Converts X0208 kankaku to double ASCII spaces.
*
* [-Z3] Replacing Fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
*
* === -X -x
*
* Assume X0201 kana in MS-Kanji.
* With <b>-X</b> or without this option, X0201 is converted into X0208 Kana.
* With <b>-x</b>, try to preserve X0208 kana and do not convert X0201 kana to X0208.
* In JIS output, ESC-(-I is used. In EUC output, SSO is used.
*
* === -B[0-2]
*
* Assume broken JIS-Kanji input, which lost ESC.
* Useful when your site is using old B-News Nihongo patch.
*
* [-B1] allows any char after ESC-( or ESC-$.
*
* [-B2] forces ASCII after NL.
*
* === -I
*
* Replacing non iso-2022-jp char into a geta character
* (substitute character in Japanese).
*
* === -d -c
*
* Delete \r in line feed, Add \r in line feed.
*
* === -m[BQN0]
*
* MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
* To see ISO8859-1 (Latin-1) -l is necessary.
*
* [-mB] Decode MIME base64 encoded stream. Remove header or other part before
* conversion.
*
* [-mQ] Decode MIME quoted stream. '_' in quoted stream is converted to space.
*
* [-mN] Non-strict decoding.
* It allows line break in the middle of the base64 encoding.
*
* [-m0] No MIME decode.
*
* === -M
*
* MIME encode. Header style. All ASCII code and control characters are intact.
* Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
*
* [-MB] MIME encode Base64 stream.
*
* [-MQ] Perfome quoted encoding.
*
* === -l
*
* Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
* <b>-s</b>, <b>-e</b> and <b>-x</b> are not compatible with this option.
*
* === -L[uwm]
*
* new line mode
* Without this option, nkf doesn't convert line breaks.
*
* [-Lu] unix (LF)
*
* [-Lw] windows (CRLF)
*
* [-Lm] mac (CR)
*
* === --fj --unix --mac --msdos --windows
*
* convert for these system
*
* === --jis --euc --sjis --mime --base64
*
* convert for named code
*
* === --jis-input --euc-input --sjis-input --mime-input --base64-input
*
* assume input system
*
* === --ic=<code>input codeset</code> --oc=<code>output codeset</code>
*
* Set the input or output codeset.
* NKF supports following codesets and those codeset name are case insensitive.
*
* [ISO-2022-JP] a.k.a. RFC1468, 7bit JIS, JUNET
*
* [EUC-JP (eucJP-nkf)] a.k.a. AT&T JIS, Japanese EUC, UJIS
*
* [eucJP-ascii] a.k.a. x-eucjp-open-19970715-ascii
*
* [eucJP-ms] a.k.a. x-eucjp-open-19970715-ms
*
* [CP51932] Microsoft Version of EUC-JP.
*
* [Shift_JIS] SJIS, MS-Kanji
*
* [CP932] a.k.a. Windows-31J
*
* [UTF-8] same as UTF-8N
*
* [UTF-8N] UTF-8 without BOM
*
* [UTF-8-BOM] UTF-8 with BOM
*
* [UTF-16] same as UTF-16BE
*
* [UTF-16BE] UTF-16 Big Endian without BOM
*
* [UTF-16BE-BOM] UTF-16 Big Endian with BOM
*
* [UTF-16LE] UTF-16 Little Endian without BOM
*
* [UTF-16LE-BOM] UTF-16 Little Endian with BOM
*
* [UTF8-MAC] NKDed UTF-8, a.k.a. UTF8-NFD (input only)
*
* === --fb-{skip, html, xml, perl, java, subchar}
*
* Specify the way that nkf handles unassigned characters.
* Without this option, --fb-skip is assumed.
*
* === --prefix= <code>escape character</code> <code>target character</code> ..
*
* When nkf converts to Shift_JIS,
* nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters.
* 1st byte of argument is the escape character and following bytes are target characters.
*
* === --disable-cp932ext
*
* Handle the characters extended in CP932 as unassigned characters.
*
* === --cap-input
*
* Decode hex encoded characters.
*
* === --url-input
*
* Unescape percent escaped characters.
*
* === --
*
* Ignore rest of -option.
*/
void
Init_nkf()
{
VALUE mKconv = rb_define_module("NKF");
VALUE mKconv = rb_define_module("NKF");
rb_define_module_function(mKconv, "nkf", rb_nkf_kconv, 2);
rb_define_module_function(mKconv, "guess", rb_nkf_guess2, 1);
rb_define_module_function(mKconv, "guess1", rb_nkf_guess1, 1);
rb_define_module_function(mKconv, "guess2", rb_nkf_guess2, 1);
rb_define_module_function(mKconv, "nkf", rb_nkf_kconv, 2);
rb_define_module_function(mKconv, "guess1", rb_nkf_guess1, 1);
rb_define_module_function(mKconv, "guess2", rb_nkf_guess2, 1);
rb_define_alias(mKconv, "guess", "guess2");
rb_define_alias(rb_singleton_class(mKconv), "guess", "guess2");
rb_define_const(mKconv, "AUTO", INT2FIX(_AUTO));
rb_define_const(mKconv, "JIS", INT2FIX(_JIS));
rb_define_const(mKconv, "EUC", INT2FIX(_EUC));
rb_define_const(mKconv, "SJIS", INT2FIX(_SJIS));
rb_define_const(mKconv, "BINARY", INT2FIX(_BINARY));
rb_define_const(mKconv, "NOCONV", INT2FIX(_NOCONV));
rb_define_const(mKconv, "ASCII", INT2FIX(_ASCII));
rb_define_const(mKconv, "UTF8", INT2FIX(_UTF8));
rb_define_const(mKconv, "UTF16", INT2FIX(_UTF16));
rb_define_const(mKconv, "UTF32", INT2FIX(_UTF32));
rb_define_const(mKconv, "UNKNOWN", INT2FIX(_UNKNOWN));
rb_define_const(mKconv, "VERSION", rb_str_new2(RUBY_NKF_VERSION));
/* for debug */
rb_define_const(mKconv, "NKF_VERSION", rb_str_new2(NKF_VERSION));
rb_define_const(mKconv, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
rb_define_const(mKconv, "REVISION", rb_str_new2(RUBY_NKF_REVISION));
/* Auto-Detect */
rb_define_const(mKconv, "AUTO", INT2FIX(_AUTO));
/* ISO-2022-JP */
rb_define_const(mKconv, "JIS", INT2FIX(_JIS));
/* EUC-JP */
rb_define_const(mKconv, "EUC", INT2FIX(_EUC));
/* Shift_JIS */
rb_define_const(mKconv, "SJIS", INT2FIX(_SJIS));
/* BINARY */
rb_define_const(mKconv, "BINARY", INT2FIX(_BINARY));
/* No conversion */
rb_define_const(mKconv, "NOCONV", INT2FIX(_NOCONV));
/* ASCII */
rb_define_const(mKconv, "ASCII", INT2FIX(_ASCII));
/* UTF-8 */
rb_define_const(mKconv, "UTF8", INT2FIX(_UTF8));
/* UTF-16 */
rb_define_const(mKconv, "UTF16", INT2FIX(_UTF16));
/* UTF-32 */
rb_define_const(mKconv, "UTF32", INT2FIX(_UTF32));
/* UNKNOWN */
rb_define_const(mKconv, "UNKNOWN", INT2FIX(_UNKNOWN));
/* Full version string of nkf */
rb_define_const(mKconv, "VERSION", rb_str_new2(RUBY_NKF_VERSION));
/* Version of nkf */
rb_define_const(mKconv, "NKF_VERSION", rb_str_new2(NKF_VERSION));
/* Release date of nkf */
rb_define_const(mKconv, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
}