68件ヒット
[1-68件を表示]
(0.137秒)
クラス
-
Encoding
:: Converter (22) - Random (11)
- String (13)
- StringScanner (22)
キーワード
- byterindex (2)
- bytesize (11)
- peek (11)
- peep (11)
-
primitive
_ convert (22)
検索結果
先頭5件
- Random
# bytes(size) -> String - String
# bytesize -> Integer - String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil - Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize) -> Symbol - Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize , options) -> Symbol
-
Random
# bytes(size) -> String (18321.0) -
ランダムなバイナリー文字列を返します。結果の文字列のサイズを指定できます。
...ランダムなバイナリー文字列を返します。結果の文字列のサイズを指定できます。
@param size 結果の文字列のサイズをバイト数で指定します。
//emlist[例][ruby]{
r2 = Random.new(1)
p r2.bytes(10) # => "%\xF4\xC1j\xEB\x80G\xFF\x8C/"
//}......ムなバイナリー文字列を返します。結果の文字列のサイズを指定できます。
@param size 結果の文字列のサイズをバイト数で指定します。
//emlist[例][ruby]{
r2 = Random.new(1)
p r2.bytes(10) # => "%\xF4\xC1j\xEB\x80G\xFF\x8C/"
//}
@see Random.bytes... -
String
# bytesize -> Integer (12319.0) -
文字列のバイト長を整数で返します。
...文字列のバイト長を整数で返します。
//emlist[例][ruby]{
#coding:UTF-8
# 実行結果は文字コードによって異なります。
p "いろは".size #=> 3
p "いろは".bytesize #=> 9
//}
@see String#size... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (349.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...していってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("ing", -1) # => 9
# ing # インデックス -1 の文字から探索を始める
# ing
# ing # 左にずらしていってここで見つか......#=> #<MatchData "o">
# 最長にするには否定戻り読み(negative look-behind)と組み合わせる
'foo'.byterindex(/(?<!o)o+/) # => 1
$~ #=> #<MatchData "oo">
# またはbyteindexを否定先読み(negative look-ahead)
'foo'.byteindex(/o+(?!.*o)/) # => 1
$~ #=> #<MatchData "oo">
'foo'.by......erindex('o', 0) # => nil
'foo'.byterindex('o', 1) # => 1
'foo'.byterindex('o', 2) # => 2
'foo'.byterindex('o', 3) # => 2
'foo'.byterindex('o', -1) # => 2
'foo'.byterindex('o', -2) # => 1
'foo'.byterindex('o', -3) # => nil
'foo'.byterindex('o', -4) # => nil
//}
@see String#rindex, String#byteindex... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize) -> Symbol (313.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...on_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytesize 変換先バッファの容量
@param options 変換の詳細を指定する定数やハッシュ
@return 変換結果を表す Symbol
options......Encoding::Converter.new("UTF-8", "EUC-JP")
src = "abc\x81あいう\u{20bb7}\xe3"
dst = ''
begin
ret = ec.primitive_convert(src, dst)
p [ret, src, dst, ec.primitive_errinfo]
case ret
when :invalid_byte_sequence
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
redo
when :undefi......fo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
when :finished
end
break
end while nil
//}
不正なバイトや変換先で未定義なバイトをエスケープしつつ変換する... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize , options) -> Symbol (313.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...on_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytesize 変換先バッファの容量
@param options 変換の詳細を指定する定数やハッシュ
@return 変換結果を表す Symbol
options......Encoding::Converter.new("UTF-8", "EUC-JP")
src = "abc\x81あいう\u{20bb7}\xe3"
dst = ''
begin
ret = ec.primitive_convert(src, dst)
p [ret, src, dst, ec.primitive_errinfo]
case ret
when :invalid_byte_sequence
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
redo
when :undefi......fo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
when :finished
end
break
end while nil
//}
不正なバイトや変換先で未定義なバイトをエスケープしつつ変換する... -
StringScanner
# peek(bytes) -> String (249.0) -
スキャンポインタから長さ bytes バイト分だけ文字列を返します。
...スキャンポインタから長さ bytes バイト分だけ文字列を返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.peek(4) # => "test"
//}
また、このメソッドを実行してもスキャンポインタは移動しません。
StringScan......わりに StringScanner#peek を使ってください。
@param bytes 0 以上の整数を指定します。
ただし、スキャン対象の文字列の長さを超える分は無視されます。
bytes が 0 のとき、またはスキャンポインタが文字列の......ror bytes に負数を与えると発生します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
p s.peek(4) # => "test"
p s.peek(20) # => "test string"
p s.peek(0) # => ""
begin
s.peek(-1)
rescue ArgumentError => err
puts err # negative string size (... -
StringScanner
# peep(bytes) -> String (249.0) -
スキャンポインタから長さ bytes バイト分だけ文字列を返します。
...スキャンポインタから長さ bytes バイト分だけ文字列を返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.peek(4) # => "test"
//}
また、このメソッドを実行してもスキャンポインタは移動しません。
StringScan......わりに StringScanner#peek を使ってください。
@param bytes 0 以上の整数を指定します。
ただし、スキャン対象の文字列の長さを超える分は無視されます。
bytes が 0 のとき、またはスキャンポインタが文字列の......ror bytes に負数を与えると発生します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
p s.peek(4) # => "test"
p s.peek(20) # => "test string"
p s.peek(0) # => ""
begin
s.peek(-1)
rescue ArgumentError => err
puts err # negative string size (...