るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.029秒)
トップページ > クラス:Encoding::Converter[x] > バージョン:2.1.0[x] > クエリ:Encoding::Converter#primitive_convert[x]

別のキーワード

  1. converter primitive_convert
  2. converter new
  3. converter putback
  4. converter asciicompat_encoding
  5. converter primitive_errinfo

ライブラリ

キーワード

検索結果

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

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

...です。

可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変...
...ay be part of larger source
:after_output => 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
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = 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_...

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

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

...です。

可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変...
...ay be part of larger source
:after_output => 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
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = 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_...

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

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

...です。

可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変...
...ay be part of larger source
:after_output => 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
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = 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_...

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

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

...です。

可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変...
...ay be part of larger source
:after_output => 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
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = 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_...

Encoding::Converter#primitive_errinfo -> Array (70.0)

直前の Encoding::Converter#primitive_convert による変換の結果を保持する五要素の配列を返します。

...直前の Encoding::Converter#primitive_convert による変換の結果を保持する五要素の配列を返します。

@return [result, enc1, enc2, error_bytes, readagain_bytes] という五要素の配列

result は直前の primitive_convert の戻り値です。
それ以外の四要素は...
... Encoding::Converter#primitive_convert と組み合わせて使います。Encoding::Converter#convert を用いている場合にも取得することはできますが、有用な使い方は難しいでしょう。

//emlist[][ruby]{
# \xff is invalid as EUC-JP.
ec = Encoding::Converter.new("E...
...F-8 (\xE3\x81\x82).
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10)
p ec.primitive_errinfo
#=> [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", ""]

# partial character is invalid
ec = Encoding::Converter.new("EUC-JP", "ISO-885...

絞り込み条件を変える

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

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

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

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

なお、Encoding::Converter#convert では、これらの例外を捕獲しても、例外を起こしたところから変換を再開することはできません。...
...文字があった場合に発生します。

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "euc-jp")
puts ec.convert("\u3042").dump #=> "\xA4\xA2"
puts ec.finish.dump #=> ""

ec = Encoding::Converter.new("euc-jp", "utf-8")
puts ec.convert("\xA4").dump #=> ""
puts...