るりまサーチ

最速Rubyリファレンスマニュアル検索!
132件ヒット [1-100件を表示] (0.066秒)
トップページ > クエリ:ruby[x] > クエリ:replace[x] > クエリ:encode[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

String#encode(**options) -> String (18195.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::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-31J には
# 存在しないの...
...ようとすると Encoding::UndefinedConversionError が発生する
str = "\u00b7\u2014"
str.encode("Windows-31J", fallback: { "\u00b7" => "\xA5".force_encoding("Windows-31J"),
"\u2014" => "\x81\x5C".force_encoding("Windows-31J") })
//}

@see String#encode!...

String#encode(encoding, **options) -> String (18195.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::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-31J には
# 存在しないの...
...ようとすると Encoding::UndefinedConversionError が発生する
str = "\u00b7\u2014"
str.encode("Windows-31J", fallback: { "\u00b7" => "\xA5".force_encoding("Windows-31J"),
"\u2014" => "\x81\x5C".force_encoding("Windows-31J") })
//}

@see String#encode!...

String#encode(encoding, from_encoding, **options) -> String (18195.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::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-31J には
# 存在しないの...
...ようとすると Encoding::UndefinedConversionError が発生する
str = "\u00b7\u2014"
str.encode("Windows-31J", fallback: { "\u00b7" => "\xA5".force_encoding("Windows-31J"),
"\u2014" => "\x81\x5C".force_encoding("Windows-31J") })
//}

@see String#encode!...

NEWS for Ruby 2.1.0 (3183.0)

NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.1.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...グが同一でも
不正なバイト列を置き換えるようになりました。
//emlist{
include_invalid_byte_string.encode("UTF-8", invalid: :replace)
//}

=== 標準添付ライブラリの更新 (優れたもののみ)

* cgi/util
* 全てのクラスメソッドをモジ...
...い名前空間を削除しました。また、古い rake の機能も削除しました。
http://rake.rubyforge.org/doc/release_notes/rake-10_1_0_rdoc.html
http://rake.rubyforge.org/doc/release_notes/rake-10_0_3_rdoc.html

* rbconfig
* 追加: RbConfig::SIZEOF C の型のサイ...

IO.for_fd(fd, mode = "r", **opts) -> IO (30.0)

オープン済みのファイルディスクリプタ fd に対する新しい IO オブジェクトを生成して返します。

...:autoclose 偽を渡すと close時/GCでのファイナライザ呼出時に fd を close しません。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...
...よる読み込みモードでのファイルオープン][ruby]{
io = IO.new(IO.sysopen("testfile"))
io.class # => IO
io.close
//}

//emlist[例:IO.for_fd による読み込み・バイナリモードでのファイルオープン][ruby]{
IO.binwrite("testfile", "\xBF\xAA\x16\x04.\b\xCB\x12\xACoeQ\...
...xFDv2\xCF9+\x81\x18")
io = IO.for_fd(IO.sysopen("testfile"), "r", binmode: true)
io.class # => IO
io.binmode? # => true
io.close
//}

//emlist[例:IO.open によるファイルオープン][ruby]{
IO.open(IO.sysopen("testfile")) { |io| p io.class } # => IO
//}...
...ん。
* :path 文字列を渡すと、IO#path メソッドがその値を返すようになります。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...

絞り込み条件を変える

IO.new(fd, mode = "r", **opts) -> IO (30.0)

オープン済みのファイルディスクリプタ fd に対する新しい IO オブジェクトを生成して返します。

...:autoclose 偽を渡すと close時/GCでのファイナライザ呼出時に fd を close しません。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...
...よる読み込みモードでのファイルオープン][ruby]{
io = IO.new(IO.sysopen("testfile"))
io.class # => IO
io.close
//}

//emlist[例:IO.for_fd による読み込み・バイナリモードでのファイルオープン][ruby]{
IO.binwrite("testfile", "\xBF\xAA\x16\x04.\b\xCB\x12\xACoeQ\...
...xFDv2\xCF9+\x81\x18")
io = IO.for_fd(IO.sysopen("testfile"), "r", binmode: true)
io.class # => IO
io.binmode? # => true
io.close
//}

//emlist[例:IO.open によるファイルオープン][ruby]{
IO.open(IO.sysopen("testfile")) { |io| p io.class } # => IO
//}...
...ん。
* :path 文字列を渡すと、IO#path メソッドがその値を返すようになります。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...

IO.open(fd, mode = "r", **opts) -> IO (30.0)

オープン済みのファイルディスクリプタ fd に対する新しい IO オブジェクトを生成して返します。

...:autoclose 偽を渡すと close時/GCでのファイナライザ呼出時に fd を close しません。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...
...よる読み込みモードでのファイルオープン][ruby]{
io = IO.new(IO.sysopen("testfile"))
io.class # => IO
io.close
//}

//emlist[例:IO.for_fd による読み込み・バイナリモードでのファイルオープン][ruby]{
IO.binwrite("testfile", "\xBF\xAA\x16\x04.\b\xCB\x12\xACoeQ\...
...xFDv2\xCF9+\x81\x18")
io = IO.for_fd(IO.sysopen("testfile"), "r", binmode: true)
io.class # => IO
io.binmode? # => true
io.close
//}

//emlist[例:IO.open によるファイルオープン][ruby]{
IO.open(IO.sysopen("testfile")) { |io| p io.class } # => IO
//}...
...ん。
* :path 文字列を渡すと、IO#path メソッドがその値を返すようになります。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...

IO.open(fd, mode = "r", **opts) {|io| ... } -> object (30.0)

オープン済みのファイルディスクリプタ fd に対する新しい IO オブジェクトを生成して返します。

...:autoclose 偽を渡すと close時/GCでのファイナライザ呼出時に fd を close しません。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...
...よる読み込みモードでのファイルオープン][ruby]{
io = IO.new(IO.sysopen("testfile"))
io.class # => IO
io.close
//}

//emlist[例:IO.for_fd による読み込み・バイナリモードでのファイルオープン][ruby]{
IO.binwrite("testfile", "\xBF\xAA\x16\x04.\b\xCB\x12\xACoeQ\...
...xFDv2\xCF9+\x81\x18")
io = IO.for_fd(IO.sysopen("testfile"), "r", binmode: true)
io.class # => IO
io.binmode? # => true
io.close
//}

//emlist[例:IO.open によるファイルオープン][ruby]{
IO.open(IO.sysopen("testfile")) { |io| p io.class } # => IO
//}...
...ん。
* :path 文字列を渡すと、IO#path メソッドがその値を返すようになります。
また、String#encode で説明されている :invalid => :replace などの
変換オプションも指定することができます。外部エンコーディングから
内部エンコ...

Encoding::Converter.new(convpath) -> Encoding::Converter (24.0)

Encoding::Converter オブジェクトを作成します。

...@param convpath 変換経路の配列

options では String#encode でのハッシュオプションに加えて、以下の定数が利用可能です。

* Encoding::Converter::INVALID_REPLACE
* Encoding::Converter::UNDEF_REPLACE
* Encoding::Converter::UNDEF_HEX_CHARREF
* Encoding::Conve...
...ng::Converter::XML_TEXT_DECORATOR
* Encoding::Converter::XML_ATTR_CONTENT_DECORATOR
* Encoding::Converter::XML_ATTR_QUOTE_DECORATOR

//emlist[][ruby]{
# UTF-16BE to UTF-8
ec = Encoding::Converter.new("UTF-16BE", "UTF-8")

# Usually, decorators such as newline conversion are inserted last.
ec = E...
<< 1 2 > >>