別のキーワード
ライブラリ
- ビルトイン (513)
- csv (12)
- kconv (12)
- open-uri (12)
-
rexml
/ document (60) -
webrick
/ httprequest (12)
クラス
- Array (21)
- CSV (12)
- Encoding (48)
-
Encoding
:: Converter (84) -
Encoding
:: InvalidByteSequenceError (12) -
Encoding
:: UndefinedConversionError (12) - Integer (24)
-
REXML
:: Document (36) -
REXML
:: Instruction (24) - String (282)
- Time (42)
-
WEBrick
:: HTTPRequest (12)
モジュール
-
OpenURI
:: Meta (12)
キーワード
- << (12)
- asctime (12)
- b (12)
- casecmp (12)
- chr (24)
- concat (21)
- content (12)
-
content
_ encoding (12) - convert (12)
- ctime (12)
- encode (36)
- encode! (24)
-
error
_ bytes (12) -
error
_ char (12) - finish (12)
-
force
_ encoding (12) -
insert
_ output (12) - inspect (30)
- iseuc (12)
- name (12)
- names (12)
- pack (21)
- putback (24)
- query (12)
- replacement (12)
- replacement= (12)
- scrub (36)
- scrub! (36)
-
stand
_ alone? (12) - target (12)
-
to
_ s (24) -
unicode
_ normalize (11) -
unicode
_ normalize! (11) -
unicode
_ normalized? (11) - unpack (12)
-
valid
_ encoding? (12) - version (12)
検索結果
先頭5件
-
String
# scrub(repl) -> String (24252.0) -
self が不正なバイト列を含む場合に別の文字列に置き換えた新しい文字列を返します。
...定します。省略した場合
は self の文字エンコーディングが Encoding::UTF_16BE,
Encoding::UTF_16LE, Encoding::UTF_32BE,
Encoding::UTF_32LE, Encoding::UTF_8 のいずれか
の場合は "\uFFFD" を表す文字で、それ以外の......ブ
ロックの戻り値で置き換えられます。
//emlist[例][ruby]{
"abc\u3042\x81".scrub # => "abc\u3042\uFFFD"
"abc\u3042\x81".scrub("*") # => "abc\u3042*"
"abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack('H*')[0]+'>' } # => "abc\u3042<e380>"
//}
@see String#scrub!... -
String
# unicode _ normalize(form = :nfc) -> String (24244.0) -
self を NFC、NFD、NFKC、NFKD のいずれかの正規化形式で Unicode 正規化し た文字列を返します。
...た場合は :nfc になります。
@raise Encoding::CompatibilityError self が Unicode 文字列ではない場合
に発生します。
このメソッドでの "Unicode 文字列" とは、UTF-8、UTF-16BE/LE、
UTF-32BE/LE だけではなく GB18030、UCS_......2BE、and UCS_4BE を含みます。
また、self が UTF-8 以外のエンコーディングであった場合は一度 UTF-8 に変
換してから正規化されるため、UTF-8 よりも遅くなっています。
//emlist[例][ruby]{
"a\u0300".unicode_normalize # => 'à' ("\u00E0"......# => 'à' ("\u00E0" と同じ)
"\u00E0".unicode_normalize(:nfd) # => 'à' ("a\u0300" と同じ)
"\xE0".force_encoding('ISO-8859-1').unicode_normalize(:nfd)
# => Encoding::CompatibilityError raised
//}
@see String#unicode_normalize!, String#unicode_normalized?... -
String
# b -> String (24238.0) -
self の文字エンコーディングを ASCII-8BIT にした文字列の複製を返します。
...self の文字エンコーディングを ASCII-8BIT にした文字列の複製を返します。
//emlist[例][ruby]{
'abc123'.encoding # => #<Encoding:UTF-8>
'abc123'.b.encoding # => #<Encoding:ASCII-8BIT>
//}... -
String
# casecmp(other) -> -1 | 0 | 1 | nil (24159.0) -
String#<=> と同様に文字列の順序を比較しますが、 アルファベットの大文字小文字の違いを無視します。
...
String#<=> と同様に文字列の順序を比較しますが、
アルファベットの大文字小文字の違いを無視します。
このメソッドの動作は組み込み変数 $= には影響されません。
@param other self と比較する文字列
//emlist[例][ruby]{
"aBcDe......=> 0
"aBcDeF".casecmp("abcdefg") #=> -1
"abcdef".casecmp("ABCDEF") #=> 0
//}
nil は文字列のエンコーディングが非互換の時に返されます。
//emlist[][ruby]{
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}") #=> nil
//}
@see String#<=>, Encoding.compatible?......
String#<=> と同様に文字列の順序を比較しますが、
アルファベットの大文字小文字の違いを無視します。
このメソッドの動作は組み込み変数 $= には影響されません。
String#casecmp? と違って大文字小文字の違いを無視するの......は
Unicode 全体ではなく、A-Z/a-z だけです。
@param other self と比較する文字列
//emlist[例][ruby]{
"aBcDeF".casecmp("abcde") #=> 1
"aBcDeF".casecmp("abcdef") #=> 0
"aBcDeF".casecmp("abcdefg") #=> -1
"abcdef".casecmp("ABCDEF") #=> 0
//}
nil は文字列のエ......ンコーディングが非互換の時に返されます。
//emlist[][ruby]{
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}") #=> nil
//}
@see String#<=>, Encoding.compatible?... -
String
# <<(other) -> self (24138.0) -
self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。
...other を破壊的に連結します。
other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。
self を返します。
@param other 文字列もしくは 0 以上の整数
//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p str # => "str......ingXXX"
str << "YYY"
p str # => "stringXXXYYY"
str << 65 # 文字AのASCIIコード
p str # => "stringXXXYYYA"
//}... -
String
# unicode _ normalized?(form = :nfc) -> bool (24043.0) -
self が引数 form で指定された正規化形式で Unicode 正規化された文字列か どうかを返します。
...aise Encoding::CompatibilityError self が Unicode 文字列ではない場合
に発生します。
//emlist[例][ruby]{
"a\u0300".unicode_normalized? # => false
"a\u0300".unicode_normalized?(:nfd) # => true
"\u00E0".unicode_normalized? # => true......"\u00E0".unicode_normalized?(:nfd) # => false
"\xE0".force_encoding('ISO-8859-1').unicode_normalized?
# => Encoding::CompatibilityError raised
//}
@see String#unicode_normalize, String#unicode_normalize!... -
String
# unicode _ normalize!(form = :nfc) -> self (24031.0) -
self を NFC、NFD、NFKC、NFKD のいずれかの正規化形式で Unicode 正規化し た文字列に置き換えます。
...。
@raise Encoding::CompatibilityError self が Unicode 文字列ではない場合
に発生します。
//emlist[例][ruby]{
text = "a\u0300"
text.unicode_normalize!(:nfc)
text == "\u00E0" # => true
text.unicode_normalize!(:nfd)
text == "a\u0300"......# => true
//}
@see String#unicode_normalize, String#unicode_normalized?... -
String
# iseuc -> bool (24025.0) -
self が EUC-JP なバイト列として正当であるかどうかを判定します。
...self) と同じです。
//emlist[例][ruby]{
require 'kconv'
euc_str = "\
\xa5\xaa\xa5\xd6\xa5\xb8\xa5\xa7\xa5\xaf\xa5\xc8\xbb\xd8\xb8\xfe\
\xa5\xd7\xa5\xed\xa5\xb0\xa5\xe9\xa5\xdf\xa5\xf3\xa5\xb0\xb8\xc0\xb8\xec\
\x52\x75\x62\x79".force_encoding('EUC-JP')
sjis_str = "\
\x83\x49\x83\x75\x83\x57\......x83\x46\x83\x4e\x83\x67\x8e\x77\x8c\xfc\
\x83\x76\x83\x8d\x83\x4f\x83\x89\x83\x7e\x83\x93\x83\x4f\x8c\xbe\x8c\xea\
\x52\x75\x62\x79".force_encoding('Shift_JIS')
euc_str.iseuc # => true
sjis_str.iseuc # => false
//}... -
REXML
:: Document # encoding -> String (21327.0) -
XML 宣言に含まれている XML 文書のエンコーディングを返します。
...宣言を持たない場合はデフォルトの値
(REXML::XMLDecl.defaultで宣言されているもの)を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<e />
EOS
doc.encoding # => "UTF-8"
//}... -
Encoding
# inspect -> String (15238.0) -
プログラマにわかりやすい表現の文字列を返します。
...プログラマにわかりやすい表現の文字列を返します。
//emlist[例][ruby]{
Encoding::UTF_8.inspect #=> "#<Encoding:UTF-8>"
Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
//}...