33件ヒット
[1-33件を表示]
(0.095秒)
検索結果
-
Encoding
:: CompatibilityError (24018.0) -
2つのエンコーディング間に互換性がない場合に発生する例外。
...い場合に発生する例外。
エンコーディングの異なる文字列を連結しようとした場合などに発生します。
//emlist[例][ruby]{
"あ".encode("EUC-JP") + "あ".encode("UTF-8")
#=> Encoding::CompatibilityError: incompatible character encodings: EUC-JP and UTF-8
//}... -
String (6060.0)
-
文字列のクラスです。 ヌル文字を含む任意のバイト列を扱うことができます。 文字列の長さにはメモリ容量以外の制限はありません。
...つか示します。
//emlist[文字列リテラルの例][ruby]{
'str\\ing' # シングルクオート文字列 (エスケープシーケンスがほぼ無効)
"string\n" # ダブルクオート文字列 (エスケープシーケンスがすべて有効)
%q(str\\ing) # 「%q」文字列 (エ......グ
String オブジェクトは自身のエンコーディング情報を持ちます。
インスタンスメソッドはエンコーディングに従い、1バイトではなく1文字を単位として動作します。
エンコーディングの変換にはメソッド String#encode を使......mlist[例:文字列の結合][ruby]{
s = "いろは"
a = s.encode("EUC-JP")
b = s.encode("UTF-8")
p a == b #=> false
s = "合".encode("EUC-JP")
p s + "\u{4f53}".encode("EUC-JP") #=> "合体"
p s + "\u{4f53}" #=> Encoding::CompatibilityError
//}
Strin... -
正規表現 (108.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...achar
* expansion
* char
* anychar
* string
* str
* quantifier
* capture
* grouping
* subexp
* selector
* anchor
* cond
* option
* encoding
* comment
* free_format_mode
* absenceop
* list
* specialvar
* references
正規表現(regular expression)は文字列......。
//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 の規......# -*- coding:utf-8 -*-
/あいう/.encoding # => #<Encoding:UTF-8>
/abc/.encoding # => #<Encoding:US-ASCII>
/abc/u.encoding # => #<Encoding:UTF-8>
//}
正規表現のエンコーディングと文字列のエンコーディングが非互換で
ある場合、Encoding::CompatibilityError が発生...