るりまサーチ

最速Rubyリファレンスマニュアル検索!
306件ヒット [201-300件を表示] (0.129秒)

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 > >>

String#scrub!(repl) -> String (12241.0)

self が不正なバイト列を含む場合に別の文字列に置き換えます。常に self を返します。

...定します。省略した場合
は self の文字エンコーディングが Encoding::UTF_16BE,
Encoding
::UTF_16LE, Encoding::UTF_32BE,
Encoding
::UTF_32LE, Encoding::UTF_8 のいずれか
の場合は "\uFFFD" を表す文字で、それ以外の...
...ロックの戻り値で置き換えられます。

//emlist[例][ruby]{
"abc\u3042\x81".scrub! # => "abc\u3042\uFFFD"
"abc\u3042\x81".scrub!("*") # => "abc\u3042*"
"abc\u3042\xE3\x80".scrub!{|bytes| '<'+bytes.unpack('H*')[0]+'>' } # => "abc\u3042<e380>"
//}

@see String#scrub...

String#scrub(repl) -> String (12241.0)

self が不正なバイト列を含む場合に別の文字列に置き換えた新しい文字列を返します。

...定します。省略した場合
は self の文字エンコーディングが Encoding::UTF_16BE,
Encoding
::UTF_16LE, Encoding::UTF_32BE,
Encoding
::UTF_32LE, Encoding::UTF_8 のいずれか
の場合は "\uFFFD" を表す文字で、それ以外の...
...
ロックの戻り値で置き換えられます。

//emlist[例][ruby]{
"abc\u3042\x81".scrub # => "abc\u3042\uFFFD"
"abc\u3042\x81".scrub("*") # => "abc\u3042*"
"abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack('H*')[0]+'>' } # => "abc\u3042<e380>"
//}

@see String#scrub!...

String#unicode_normalize(form = :nfc) -> String (12233.0)

self を NFC、NFD、NFKC、NFKD のいずれかの正規化形式で Unicode 正規化し た文字列を返します。

...た場合は :nfc になります。

@raise Encoding::CompatibilityError self が Unicode 文字列ではない場合
に発生します。

このメソッドでの "Unicode 文字列" とは、UTF-8、UTF-16BE/LE、
UTF-32BE/LE だけではなく GB18030、UCS_...
...2BE、and UCS_4BE を含みます。

また、self が UTF-8 以外のエンコーディングであった場合は一度 UTF-8 に変
換してから正規化されるため、UTF-8 よりも遅くなっています。

//emlist[例][ruby]{
"a\u0300".unicode_normalize # => 'à' ("\u00E0"...
...# => 'à' ("\u00E0" と同じ)
"\u00E0".unicode_normalize(:nfd) # => 'à' ("a\u0300" と同じ)
"\xE0".force_encoding('ISO-8859-1').unicode_normalize(:nfd)
# => Encoding::CompatibilityError raised
//}

@see String#unicode_normalize!, String#unicode_normalized?...

String#b -> String (12227.0)

self の文字エンコーディングを ASCII-8BIT にした文字列の複製を返します。

...self の文字エンコーディングを ASCII-8BIT にした文字列の複製を返します。

//emlist[例][ruby]{
'abc123'.encoding # => #<Encoding:UTF-8>
'abc123'.b.encoding # => #<Encoding:ASCII-8BIT>
//}...

String#casecmp(other) -> -1 | 0 | 1 | nil (12136.0)

String#<=> と同様に文字列の順序を比較しますが、 アルファベットの大文字小文字の違いを無視します。

...
String
#<=> と同様に文字列の順序を比較しますが、
アルファベットの大文字小文字の違いを無視します。

このメソッドの動作は組み込み変数 $= には影響されません。


@param other self と比較する文字列

//emlist[例][ruby]{
"aBcDe...
...=> 0
"aBcDeF".casecmp("abcdefg") #=> -1
"abcdef".casecmp("ABCDEF") #=> 0
//}

nil は文字列のエンコーディングが非互換の時に返されます。

//emlist[][ruby]{
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}") #=> nil
//}

@see String#<=>, Encoding.compatible?...
...
String
#<=> と同様に文字列の順序を比較しますが、
アルファベットの大文字小文字の違いを無視します。

このメソッドの動作は組み込み変数 $= には影響されません。

String
#casecmp? と違って大文字小文字の違いを無視するの...
...
Unicode 全体ではなく、A-Z/a-z だけです。

@param other self と比較する文字列

//emlist[例][ruby]{
"aBcDeF".casecmp("abcde") #=> 1
"aBcDeF".casecmp("abcdef") #=> 0
"aBcDeF".casecmp("abcdefg") #=> -1
"abcdef".casecmp("ABCDEF") #=> 0
//}

nil は文字列のエ...
...ンコーディングが非互換の時に返されます。

//emlist[][ruby]{
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}") #=> nil
//}

@see String#<=>, Encoding.compatible?...

絞り込み条件を変える

String#<<(other) -> self (12125.0)

self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

...other を破壊的に連結します。
other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

self を返します。

@param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p str # => "str...
...ingXXX"

str << "YYY"
p str # => "stringXXXYYY"

str << 65 # 文字AのASCIIコード
p str # => "stringXXXYYYA"
//}...

String#scanf(format) -> Array (12120.0)

ブロックを指定しない場合、見つかった文字列を format に従って変 換し、そのオブジェクトの配列を返します。 format で指定した文字列が見つからない場合は空の配列を 生成して返します。

...かった文字列を format に従って変
換し、そのオブジェクトの配列を返します。
format で指定した文字列が見つからない場合は空の配列を
生成して返します。

require 'scanf'
str = "123 abc 456 def 789 ghi"
p str.scanf("%d%s") #=> [123, "abc...
...'scanf'
str = "123 0x45 678 0x90"
p str.scanf("%d%x"){|n, s| [n, s]}
#=> [[123, 69], [678, 144]]

formatに完全にマッチしていなくても、部分的にマッチしていれば、
ブロックは実行されます。

require 'scanf'
str = "123 abc 456 def"
ret = str.scanf("%s%...
...}
p ret #=> [["123", nil], ["abc", 456], ["def", nil]]


@param format スキャンするフォーマットを文字列で指定します。
詳細は、m:String#scanf#format を参照してください。

使用例:
require 'scanf'
str = "123 abc 456 def 789 ghi"
p str.scanf(...

String#scanf(format) {|*ary| ...} -> Array (12120.0)

ブロックを指定しない場合、見つかった文字列を format に従って変 換し、そのオブジェクトの配列を返します。 format で指定した文字列が見つからない場合は空の配列を 生成して返します。

...かった文字列を format に従って変
換し、そのオブジェクトの配列を返します。
format で指定した文字列が見つからない場合は空の配列を
生成して返します。

require 'scanf'
str = "123 abc 456 def 789 ghi"
p str.scanf("%d%s") #=> [123, "abc...
...'scanf'
str = "123 0x45 678 0x90"
p str.scanf("%d%x"){|n, s| [n, s]}
#=> [[123, 69], [678, 144]]

formatに完全にマッチしていなくても、部分的にマッチしていれば、
ブロックは実行されます。

require 'scanf'
str = "123 abc 456 def"
ret = str.scanf("%s%...
...}
p ret #=> [["123", nil], ["abc", 456], ["def", nil]]


@param format スキャンするフォーマットを文字列で指定します。
詳細は、m:String#scanf#format を参照してください。

使用例:
require 'scanf'
str = "123 abc 456 def 789 ghi"
p str.scanf(...

String#unicode_normalized?(form = :nfc) -> bool (12032.0)

self が引数 form で指定された正規化形式で Unicode 正規化された文字列か どうかを返します。

...aise Encoding::CompatibilityError self が Unicode 文字列ではない場合
に発生します。

//emlist[例][ruby]{
"a\u0300".unicode_normalized? # => false
"a\u0300".unicode_normalized?(:nfd) # => true
"\u00E0".unicode_normalized? # => true...
..."\u00E0".unicode_normalized?(:nfd) # => false
"\xE0".force_encoding('ISO-8859-1').unicode_normalized?
# => Encoding::CompatibilityError raised
//}

@see String#unicode_normalize, String#unicode_normalize!...

String#unicode_normalize!(form = :nfc) -> self (12020.0)

self を NFC、NFD、NFKC、NFKD のいずれかの正規化形式で Unicode 正規化し た文字列に置き換えます。

...

@raise Encoding::CompatibilityError self が Unicode 文字列ではない場合
に発生します。

//emlist[例][ruby]{
t
ext = "a\u0300"
t
ext.unicode_normalize!(:nfc)
t
ext == "\u00E0" # => true
t
ext.unicode_normalize!(:nfd)
t
ext == "a\u0300"...
...# => true
//}

@see String#unicode_normalize, String#unicode_normalized?...

絞り込み条件を変える

String#iseuc -> bool (12014.0)

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

...self) と同じです。

//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\xf3\xa5\xb0\xb8\xc0\xb8\xec\
\x52\x75\x62\x79".force_encoding('EUC-JP')

sjis_str = "\
\x83\x49\x83\x75\x83\x57\...
...x83\x46\x83\x4e\x83\x67\x8e\x77\x8c\xfc\
\x83\x76\x83\x8d\x83\x4f\x83\x89\x83\x7e\x83\x93\x83\x4f\x8c\xbe\x8c\xea\
\x52\x75\x62\x79".force_encoding('Shift_JIS')

euc_str.iseuc # => true
sjis_str.iseuc # => false
//}...
<< < 1 2 3 4 > >>