Module: URITemplate::Utils::StringEncoding::Encode
- Included in:
- URITemplate::Utils::StringEncoding
- Defined in:
- lib/uri_template/utils.rb
Overview
Methods which do actual encoding.
Instance Method Summary collapse
-
#force_utf8(str) ⇒ Object
enforces UTF8 encoding.
-
#to_ascii(str) ⇒ Object
converts a string to ascii.
-
#to_utf8(str) ⇒ Object
converts a string to utf8.
Instance Method Details
#force_utf8(str) ⇒ Object
enforces UTF8 encoding
109 110 111 112 113 |
# File 'lib/uri_template/utils.rb', line 109 def force_utf8(str) return str if str.encoding == Encoding::UTF_8 str = str.dup if str.frozen? return str.force_encoding(Encoding::UTF_8) end |
#to_ascii(str) ⇒ Object
converts a string to ascii
91 92 93 |
# File 'lib/uri_template/utils.rb', line 91 def to_ascii(str) str.encode(Encoding::ASCII) end |
#to_utf8(str) ⇒ Object
converts a string to utf8
100 101 102 |
# File 'lib/uri_template/utils.rb', line 100 def to_utf8(str) str.encode(Encoding::UTF_8) end |