| Module | Kconv |
| In: |
nkf/lib/kconv.rb
|
Kanji Converter for Ruby.
| AUTO | = | NKF::AUTO | Auto-Detect | |
| JIS | = | NKF::JIS | ISO-2022-JP | |
| EUC | = | NKF::EUC | EUC-JP | |
| SJIS | = | NKF::SJIS | Shift_JIS | |
| BINARY | = | NKF::BINARY | BINARY | |
| NOCONV | = | NKF::NOCONV | NOCONV | |
| ASCII | = | NKF::ASCII | ASCII | |
| UTF8 | = | NKF::UTF8 | UTF-8 | |
| UTF16 | = | NKF::UTF16 | UTF-16 | |
| UTF32 | = | NKF::UTF32 | UTF-32 | |
| UNKNOWN | = | NKF::UNKNOWN | UNKNOWN | |
| REVISION | = | %q$Revision: 11708 $ | Revision of kconv.rb | |
| RegexpShiftjis | = | /\A(?: [\x00-\x7f\xa1-\xdf] | [\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc] )*\z/nx | Regexp of Shift_JIS string (private constant) | |
| RegexpEucjp | = | /\A(?: [\x00-\x7f] | \x8e [\xa1-\xdf] | \x8f [\xa1-\xfe] [\xa1-\xfe] | [\xa1-\xfe] [\xa1-\xfe] )*\z/nx | Regexp of EUC-JP string (private constant) | |
| RegexpUtf8 | = | /\A(?: [\x00-\x7f] | [\xc2-\xdf] [\x80-\xbf] | \xe0 [\xa0-\xbf] [\x80-\xbf] | [\xe1-\xef] [\x80-\xbf] [\x80-\xbf] | \xf0 [\x90-\xbf] [\x80-\xbf] [\x80-\xbf] | [\xf1-\xf3] [\x80-\xbf] [\x80-\xbf] [\x80-\xbf] | \xf4 [\x80-\x8f] [\x80-\xbf] [\x80-\xbf] )*\z/nx | Regexp of UTF-8 string (private constant) |
Guess input encoding by NKF.guess2
# File nkf/lib/kconv.rb, line 213 def guess(str) ::NKF::guess(str) end
Guess input encoding by NKF.guess1
# File nkf/lib/kconv.rb, line 222 def guess_old(str) ::NKF::guess1(str) end
Returns whether input encoding is EUC-JP or not.
Note don‘t expect this return value is MatchData.
# File nkf/lib/kconv.rb, line 237 def iseuc(str) RegexpEucjp.match( str ) end
Returns whether input encoding is Shift_JIS or not.
Note don‘t expect this return value is MatchData.
# File nkf/lib/kconv.rb, line 248 def issjis(str) RegexpShiftjis.match( str ) end
Returns whether input encoding is UTF-8 or not.
Note don‘t expect this return value is MatchData.
# File nkf/lib/kconv.rb, line 259 def isutf8(str) RegexpUtf8.match( str ) end
Convert str to out_code. out_code and in_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.
# File nkf/lib/kconv.rb, line 95 def kconv(str, out_code, in_code = AUTO) opt = '-' case in_code when ::NKF::JIS opt << 'J' when ::NKF::EUC opt << 'E' when ::NKF::SJIS opt << 'S' when ::NKF::UTF8 opt << 'W' when ::NKF::UTF16 opt << 'W16' end case out_code when ::NKF::JIS opt << 'j' when ::NKF::EUC opt << 'e' when ::NKF::SJIS opt << 's' when ::NKF::UTF8 opt << 'w' when ::NKF::UTF16 opt << 'w16' when ::NKF::NOCONV return str end opt = '' if opt == '-' ::NKF::nkf(opt, str) end
ruby-doc.org is a service of James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, AZ.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.