るりまサーチ

最速Rubyリファレンスマニュアル検索!
142件ヒット [1-100件を表示] (0.063秒)

別のキーワード

  1. stringio set_encoding
  2. _builtin set_encoding
  3. _builtin encoding
  4. rss encoding
  5. rss encoding=

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

String#force_encoding(encoding) -> self (24410.0)

文字列の持つエンコーディング情報を指定された encoding に変えます。

...情報を指定された encoding に変えます。

このとき実際のエンコーディングは変換されず、検査もされません。
Array#pack などで得られたバイト列のエンコーディングを指定する時に使います。

@
param encoding 変更するエンコー...
...す文字列か Encoding オブジェクトを指定します。

//emlist[例][ruby]{
s = [164, 164, 164, 237, 164, 207].pack("C*")
p s.encoding #=> ASCII-8BIT
p s.force_encoding("EUC-JP") #=> "いろは"
p s.force_encoding(Encoding::EUC_JP)...
...#=> "いろは"

u = [12411, 12408, 12392].pack("U*")
u.force_encoding("UTF-8") #=> "ほへと"
u.force_encoding(Encoding::UTF_8) #=> "ほへと"
//}...

Encoding::Converter#convert(source_string) -> String (3149.0)

与えられた文字列を変換して、変換できた結果を返します。 引数の末尾の文字がバイト列の途中で終わっている場合、そのバイト列は変換器内に取り置かれます。 変換を終了させるには Encoding::Converter#finish を呼びます。

...で終わっている場合、そのバイト列は変換器内に取り置かれます。
変換を終了させるには Encoding::Converter#finish を呼びます。

Encoding
::Converter を用いると、文字列の一部または全部を渡して変換を行うことができます。よって...
...トを意識せずにストリームから読み出した文字列を変換したいときには Encoding::Converter が適します。

なお、Encoding::Converter#convert では、これらの例外を捕獲しても、例外を起こしたところから変換を再開することはできませ...
...場合は、Encoding::Converter#primitive_convert を用います。

@
param source_string 変換する文字列の一部または全部です。
@
return 変換結果である文字列の一部または全部です。
@
raise Encoding::InvalidByteSequenceError 変換元のエンコーディングに...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer) -> Symbol (3091.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...ときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param desti...
...nation_bytesize 変換先バッファの容量
@
param options 変換の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_o...
...utput => true # stop conversion after output before input
: integer form
Encoding
::Converter::PARTIAL_INPUT
Encoding
::Converter::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset) -> Symbol (3091.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...ときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param desti...
...nation_bytesize 変換先バッファの容量
@
param options 変換の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_o...
...utput => true # stop conversion after output before input
: integer form
Encoding
::Converter::PARTIAL_INPUT
Encoding
::Converter::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) -> Symbol (3091.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...ときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param desti...
...nation_bytesize 変換先バッファの容量
@
param options 変換の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_o...
...utput => true # stop conversion after output before input
: integer form
Encoding
::Converter::PARTIAL_INPUT
Encoding
::Converter::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output...

絞り込み条件を変える

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, options) -> Symbol (3091.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...ときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param desti...
...nation_bytesize 変換先バッファの容量
@
param options 変換の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_o...
...utput => true # stop conversion after output before input
: integer form
Encoding
::Converter::PARTIAL_INPUT
Encoding
::Converter::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output...

Encoding::Converter#insert_output(string) -> nil (3049.0)

変換器内のバッファに文字列を挿入します。 バッファに保持された文字列は、次の変換時の変換結果と一緒に返されます。

...す。

このメソッドは変換に際してエラーが発生した際にのみ利用されるべきです。

@
param string 挿入する文字列

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
src = "HIRAGANA LETTER A is \u{3042}."
dst = ""
p ec.primitive_convert(src, ds...
...r>.", ""]

ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp
dst = ""
p ec.primitive_convert(src, dst) #=> :undefined_conversion
puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP")...
..., "\xE3\ x80\x82"]
ec.insert_output "?" # state change required to output "?".
p ec.primitive_convert(src, dst) #=> :finished
puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H\e(B?\e$B!#\e(B".force_encoding("ISO-20 22-JP"), ""]
//}...

String#encode(encoding, from_encoding, **options) -> String (334.0)

self を指定したエンコーディングに変換した文字列を作成して返します。引数 を2つ与えた場合、第二引数は変換元のエンコーディングを意味します。さもな くば self のエンコーディングが使われます。 無引数の場合は、Encoding.default_internal が nil でなければそれが変換先のエンコーディングになり、かつ :invalid => :replace と :undef => :replace が指定されたと見なされ、nil ならば変換は行われません。

...無引数の場合は、Encoding.default_internal が nil でなければそれが変換先のエンコーディングになり、かつ :invalid => :replace と :undef => :replace が指定されたと見なされ、nil ならば変換は行われません。

@
param encoding 変換先のエ...
...す文字列か Encoding オブジェクトを指定します。
@
param from_encoding 変換元のエンコーディングを表す文字列か Encoding オブジェクトを指定します。
@
param option 変換オプションをキーワード引数で与えます。
@
return...
...

変換オプション

: :invalid => nil
変換元のエンコーディングにおいて不正なバイトがあった場合に、例外 Encoding::InvalidByteSequenceError を投げます。(デフォルト)
: :invalid => :replace
変換元のエンコーディングにおいて不正な...

String#encode(encoding, **options) -> String (234.0)

self を指定したエンコーディングに変換した文字列を作成して返します。引数 を2つ与えた場合、第二引数は変換元のエンコーディングを意味します。さもな くば self のエンコーディングが使われます。 無引数の場合は、Encoding.default_internal が nil でなければそれが変換先のエンコーディングになり、かつ :invalid => :replace と :undef => :replace が指定されたと見なされ、nil ならば変換は行われません。

...無引数の場合は、Encoding.default_internal が nil でなければそれが変換先のエンコーディングになり、かつ :invalid => :replace と :undef => :replace が指定されたと見なされ、nil ならば変換は行われません。

@
param encoding 変換先のエ...
...す文字列か Encoding オブジェクトを指定します。
@
param from_encoding 変換元のエンコーディングを表す文字列か Encoding オブジェクトを指定します。
@
param option 変換オプションをキーワード引数で与えます。
@
return...
...

変換オプション

: :invalid => nil
変換元のエンコーディングにおいて不正なバイトがあった場合に、例外 Encoding::InvalidByteSequenceError を投げます。(デフォルト)
: :invalid => :replace
変換元のエンコーディングにおいて不正な...
<< 1 2 > >>