るりまサーチ

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

別のキーワード

  1. csv force_quotes?
  2. string force_encoding
  3. _builtin force_encoding
  4. lazy force
  5. options force_update

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

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

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

...ます。

@
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 (55.0)

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

...たい場合は、Encoding::Converter#primitive_convert を用います。

@
param source_string 変換する文字列の一部または全部です。
@
return 変換結果である文字列の一部または全部です。
@
raise Encoding::InvalidByteSequenceError 変換元のエンコーディン...
...において不正なバイト列があった場合に発生します。
@
raise Encoding::UndefinedConversionError 変換先のエンコーディングで未定義な文字があった場合に発生します。

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "euc-jp")
puts ec.convert("\u30...
...ec.convert("\xE3").dump #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x81").dump #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x82").dump #=> "\e$B$\"".force_encoding("ISO-2022-JP")
puts ec.finish.dump #=> "\e(B".force_encoding("ISO-2022-JP")
//}...

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

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

...になります。

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

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

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...e
* :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...

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

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

...になります。

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

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

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...e
* :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...

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

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

...になります。

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

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

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...e
* :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...

絞り込み条件を変える

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

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

...になります。

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

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

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...e
* :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...

String#encode(**options) -> String (49.0)

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

...われません。

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

変換オプション

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

これ以上細かい指定を行いたい場合は、Encoding::Converter#convert を用いましょう。

//emlist[例][ruby]{
#coding:UTF-8
s = "いろは"
s.encode("EUC-JP")
s.encode(Encoding::UTF_8)

# U+00B7 MIDDLE DOT, U+2014 EM DASH は対応する文字が Windows-...

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

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

...われません。

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

変換オプション

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

これ以上細かい指定を行いたい場合は、Encoding::Converter#convert を用いましょう。

//emlist[例][ruby]{
#coding:UTF-8
s = "いろは"
s.encode("EUC-JP")
s.encode(Encoding::UTF_8)

# U+00B7 MIDDLE DOT, U+2014 EM DASH は対応する文字が Windows-...

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

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

...われません。

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

変換オプション

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

これ以上細かい指定を行いたい場合は、Encoding::Converter#convert を用いましょう。

//emlist[例][ruby]{
#coding:UTF-8
s = "いろは"
s.encode("EUC-JP")
s.encode(Encoding::UTF_8)

# U+00B7 MIDDLE DOT, U+2014 EM DASH は対応する文字が Windows-...
<< 1 2 > >>