別のキーワード
キーワード
- Marshal フォーマット (12)
-
NEWS for Ruby 2
. 0 . 0 (12) - String (12)
-
decode
_ www _ form _ component (12) -
encode
_ www _ form _ component (12) - escape (7)
- u (12)
-
url
_ encode (12) - 正規表現 (12)
検索結果
先頭5件
-
URI
. encode(str , unsafe = URI :: UNSAFE) -> String (18155.0) -
URI 文字列をエンコードした文字列を返します。
...RI 文字列をエンコードした文字列を返します。
このメソッドは obsolete です。
代わりに
ERB::Util.#url_encode,
CGI.escape,
URI.encode_www_form_component,
WEBrick::HTTPUtils.#escape_form,
WEBrick::HTTPUtils.#escape
などの使用を検討してください。
詳細......require 'uri'
p URI.escape('http://images.google.co.jp/images?q=モナリザ&ie=EUC-JP')
#=> "http://images.google.co.jp/images?q=%A5%E2%A5%CA%A5%EA%A5%B6&ie=EUC-JP"
@param str URI を文字列として与えます。
@param unsafe URI として指定できない文字を正規表現か... -
URI
. encode _ www _ form _ component(str , enc=nil) -> String (6317.0) -
文字列を URL-encoded form data の1コンポーネント としてエンコードした文字列を返します。
...URL-encoded form data の1コンポーネント
としてエンコードした文字列を返します。
通常は URI.encode_www_form を使うほうがよいでしょう。
このメソッドでは *, -, ., 0-9, A-Z, _, a-z, は変換せず、
空白は + に変換し、その他は %XX に、......s.html#url-encoded-form-data
にもとづいて実装されています。
//emlist[][ruby]{
require 'uri'
p URI.encode_www_form_component('Ruby リファレンスマニュアル')
# => "Ruby+%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9%E3%83%9E%E3%83%8B%E3%83%A5%E3%82%A2%E3%83%AB"
//}
@......param str エンコードする文字列
@param enc 指定された場合、パーセントエンコーディングする前に、strをこのエンコーディングに変換
@see URI.decode_www_form_component, URI.encode_www_form... -
ERB
:: Util . # url _ encode(s) -> String (3155.0) -
文字列 s を URLエンコードした文字列を返します。
...を返します(CGI.escapeとほぼ同じです)。
@param s URLエンコードを行う文字列
//emlist[例][ruby]{
require "erb"
include ERB::Util
puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
//}... -
URI
. escape(str , unsafe = URI :: UNSAFE) -> String (3055.0) -
URI 文字列をエンコードした文字列を返します。
...RI 文字列をエンコードした文字列を返します。
このメソッドは obsolete です。
代わりに
ERB::Util.#url_encode,
CGI.escape,
URI.encode_www_form_component,
WEBrick::HTTPUtils.#escape_form,
WEBrick::HTTPUtils.#escape
などの使用を検討してください。
詳細......require 'uri'
p URI.escape('http://images.google.co.jp/images?q=モナリザ&ie=EUC-JP')
#=> "http://images.google.co.jp/images?q=%A5%E2%A5%CA%A5%EA%A5%B6&ie=EUC-JP"
@param str URI を文字列として与えます。
@param unsafe URI として指定できない文字を正規表現か... -
URI
. decode _ www _ form _ component(str , enc=Encoding :: UTF _ 8) -> String (204.0) -
URL-encoded form data の文字列の各コンポーネント をデコードした文字列を返します。
...URL-encoded form data の文字列の各コンポーネント
をデコードした文字列を返します。
通常は URI.decode_www_form を使うほうがよいでしょう。
"+" という文字は空白文字にデコードします。
enc で指定したエンコーディングの文字......html#urlencoded-form-data
にもとづいて実装されています。
//emlist[][ruby]{
require 'uri'
enc = URI.encode_www_form_component('Ruby リファレンスマニュアル')
# => "Ruby+%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9%E3%83%9E%E3%83%8B%E3%83%A5%E3%82%A2%E3%83%AB"
p UR......_www_form_component(enc)
# => "Ruby リファレンスマニュアル"
//}
@param str デコード対象の文字列
@param enc エンコーディング
@raise ArgumentError str のフォーマットが不正である場合に発生します
@see URI.encode_www_form_component, URI.decode_www_form... -
String (66.0)
-
文字列のクラスです。 ヌル文字を含む任意のバイト列を扱うことができます。 文字列の長さにはメモリ容量以外の制限はありません。
...# ダブルクオート文字列 (エスケープシーケンスがすべて有効)
%q(str\\ing) # 「%q」文字列 (エスケープシーケンスがほぼ無効、デリミタが変えられる)
%Q(string\n) # 「%Q」文字列 (エスケープシーケンスがすべて有効、デリミタが......ィングに従い、1バイトではなく1文字を単位として動作します。
エンコーディングの変換にはメソッド String#encode を使います。
//emlist[例:エンコーディングの変換][ruby]{
p "いろは".size #=> 3
p "漢字"[0] #=> "漢"
p "山本......すね)
p "ループ".reverse #=> "プール"
s = "ruビー"
s[0..1] = "ル"
p s #=> "ルビー"
e = "言語".encode("EUC-JP")
u = "言語".encode("UTF-8")
p e.encoding #=> Encoding::EUC_JP
p u.encoding #=> Encoding::UTF_8
//}
より詳しく... -
ERB
:: Util . # u(s) -> String (55.0) -
文字列 s を URLエンコードした文字列を返します。
...を返します(CGI.escapeとほぼ同じです)。
@param s URLエンコードを行う文字列
//emlist[例][ruby]{
require "erb"
include ERB::Util
puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
//}... -
NEWS for Ruby 2
. 0 . 0 (30.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...い。
== 1.9.3 以降の変更
=== 言語仕様の変更
* キーワード引数を追加しました
* %i, %I をシンボルの配列作成のために追加しました。(%w, %W に似ています)
* デフォルトのソースエンコーディングを US-ASCII から UTF-8 に変更......ーを危険なシリアライゼーションに関する脆弱性から保護するためです。
* iconv
* 削除しました。String#encode を使ってください。
* io/console
* 追加: IO#cooked which sets the terminal to cooked mode within the given block.
* 追加: IO#......AP.default_imaps_port
* objspace
* 追加: ObjectSpace.#reachable_objects_from
* openssl
* Consistently raise an error when trying to encode nil values. All instances
of OpenSSL::ASN1::Primitive now raise TypeError when calling to_der on an
instance whose value is nil. All... -
正規表現 (24.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...判定し、
また含んでいるならばそれが文字列中のどの場所であるかを知ることができます。
//emlist[][ruby]{
/pat/
%r{pat}
//}
などの正規表現リテラルや Regexp.new などで正規表現
オブジェクトを得ることができます。
===[a:metacha......対応を取るためにも使えます。
//emlist[][ruby]{
# ここでは <b> と </b> の対応を取る
%r{<b>.*</b>}.match("<b>x</b>y<b>z</b>") # => #<MatchData "<b>x</b>y<b>z</b>">
%r{<b>.*?</b>}.match("<b>x</b>y<b>z</b>") # => #<MatchData "<b>x</b>">
//}
====[a:quantifier_possesive] 絶対......//emlist[][ruby]{
# -*- coding:utf-8 -*-
# デフォルトは UTF-8
/foo\b/.match("あいうfoo%") # => #<MatchData "foo">
/\bfoo\b/.match("あいうfoo%") # => nil
/\bfoo\b/e.match("(foo)".encode("EUC-JP")) # => nil
/\bfoo\b/.match("(foo)") # => #<MatchData "foo">
//}
Unicode の規格... -
Marshal フォーマット (12.0)
-
Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。
...n = (0xffffff00 | n1) &
(0xffff00ff | n2 * 0x100) &
(0xff00ffff | n3 * 0x10000) &
(0x00ffffff | n4 * 0x1000000)
# p "%x" % n
n = -((n ^ 0xffff_ffff) + 1) if len < 0
n
end
p Marshal.dump(-125).unpack("x2 acC*") # => ["i", -1, 131]
p foo(-1, 131)......":", 9, "@one", "i", 6]
//}
=== Float
'f' で始まるデータ構造になります。
//emlist{
| 'f' | 数値列の長さ(Fixnum形式) | "%.16g" の文字列 |
//}
//emlist[][ruby]{
p Marshal.dump(Math::PI).unpack("x2 a c a*")
# => ["f", 22, "3.141592653589793"]
p Marshal.dump(0.0/0).u......つかない内部的なインスタンス変数としてダンプされます。
//emlist[例: euc-jp の時][ruby]{
p Marshal.dump("hogehoge".encode("euc-jp")).unpack("x2 a a c a8 c a ca8 aca*")
# => ["I", "\"", 13, "hogehoge", 6, ":", 13, "encoding", "\"", 11, "EUC-JP"]
//}
ruby 1.9.2 以降で...