るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.011秒)
トップページ > クエリ:kconv[x] > クエリ:isjis[x] > モジュール:Kconv[x]

別のキーワード

  1. kconv kconv
  2. kconv issjis
  3. kconv tosjis
  4. kconv tojis

ライブラリ

検索結果

Kconv.#isjis(str) -> bool (35126.0)

文字列 str が ISO-2022-JP なバイト列として正当であるかどうかを判定します。

...022-JP なバイト列として正当であるかどうかを判定します。

@param str 判定対象の文字列
@see String#isjis

//emlist[例][ruby]{
require 'kconv'

euc_str = "\
\xa5\xaa\xa5\xd6\xa5\xb8\xa5\xa7\xa5\xaf\xa5\xc8\xbb\xd8\xb8\xfe\
\xa5\xd7\xa5\xed\xa5\xb0\xa5\xe9\xa5\xdf\xa5\xf...
...coding('EUC-JP')

jis_str = "\
\x1b\x24\x42\x25\x2a\x25\x56\x25\x38\x25\x27\x25\x2f\x25\x48\x3b\x58\x38\x7e\
\x25\x57\x25\x6d\x25\x30\x25\x69\x25\x5f\x25\x73\x25\x30\x38\x40\x38\x6c\x1b\x28\x42\
\x52\x75\x62\x79".force_encoding('ISO-2022-JP')

euc_str.isjis # => false
jis_str.isjis # => true
//}...