るりまサーチ

最速Rubyリファレンスマニュアル検索!
36件ヒット [1-36件を表示] (0.050秒)
トップページ > クエリ:正規表現[x] > クエリ:encoding::compatibilityerror[x]

別のキーワード

  1. 正規表現 matchdata
  2. 正規表現 symbol
  3. 正規表現 spec/m17n
  4. 正規表現

ライブラリ

クラス

キーワード

検索結果

正規表現 (15351.0)

正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references

...正規表現
* metachar
* expansion
* char
* anychar
* string
* str
* quantifier
* capture
* grouping
* subexp
* selector
* anchor
* cond
* option
* encoding
* comment
* free_format_mode
* absenceop
* list
* specialvar
* references


正規表現
(regular ex...
...ession)は文字列のパターンを記述するための言語です。
また、この言語で記述されたパターンも正規表現と呼びます。

正規表現
を用いると、文字列が指定したパターンを含んでいるかどうかを判定し、
また含んでいるなら...
...-8>
//}

正規表現
のエンコーディングと文字列のエンコーディングが非互換で
ある場合、Encoding::CompatibilityError が発生します。

エンコーディングについては spec/m17n も参考にしてください。

Regexp#fixed_encoding? で正規表現のエ...

多言語化 (48.0)

多言語化 Ruby は US-ASCII はもちろん、US-ASCII 以外の文字エンコーディングもサポートしています。 文字列の内部表現のエンコーディングは固定されておらず、 プログラマは目的に応じて使用するエンコーディングを選ぶことができます。

...できます。(magic_comment)
文字列リテラルや正規表現リテラルだけでなく変数名、メソッド名、クラス名などにも
非 ASCII 文字を使うことができます。ただし文字列リテラル・正規表現リテラル以外での非 ASCII 文字の使用は
...
...ンコーディング
スクリプトエンコーディングに使えません。またエンコーディングが固定されていない
正規表現
がマッチングを行うと例外が発生します。UTF-16LE, UTF-16BE などがこれにあたります。
: ダミーエンコーディ...
...との結合ができません。
例外 (Encoding::CompatibilityError) が発生します。

//emlist[][ruby]{
p Encoding::ISO_2022_JP.dummy? # => true
s = "漢字".encode("ISO-2022-JP")
p s[0] #=> "\e"
s + "b" #=> Encoding::CompatibilityError: incompatible character encodings: ISO-2022-JP a...

Regexp#fixed_encoding? -> bool (28.0)

正規表現が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。

...
正規表現
が任意の ASCII 互換エンコーディングとマッチ可能な時に false を返します。

//emlist[例][ruby]{
# -*- coding:utf-8 -*-

r = /a/
r.fixed_encoding? # => false
r.encoding # => #<Encoding:US-ASCII...
...# => 2
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encoding::CompatibilityError
end
r =~ "abc".force_encoding("euc-jp") # => 0

r = /\u{6666}/
r.fixed_encoding? # => true
r...
...# => #<Encoding:UTF-8>
r =~ "\u{6666} a" # => 0
begin
r =~ "\xa1\xa2".force_encoding("euc-jp")
rescue => e
e.class # => Encoding::CompatibilityError
end
r =~ "abc".force_encoding("euc-jp") # => nil
//}...