Module: WTF8::ModifiedUTF8
- Defined in:
- lib/wtf8/modified_utf8.rb,
sig/wtf8/modified_utf8.rbs
Constant Summary collapse
- NUL =
"\x00"- ENCODED_NUL =
"\xC0\x80"
Class Method Summary collapse
-
.decode(bytes, strict: true) ⇒ ::String
: (::String, ?strict: bool) -> ::String.
-
.encode(bytes) ⇒ ::String
: (::String) -> ::String.
Class Method Details
.decode(bytes, strict: true) ⇒ ::String
: (::String, ?strict: bool) -> ::String
14 15 16 |
# File 'lib/wtf8/modified_utf8.rb', line 14 def self.decode(bytes, strict: true) CESU8.decode(bytes.b.gsub(ENCODED_NUL.b, NUL.b), strict: strict) end |
.encode(bytes) ⇒ ::String
: (::String) -> ::String
9 10 11 |
# File 'lib/wtf8/modified_utf8.rb', line 9 def self.encode(bytes) CESU8.encode(bytes).gsub(NUL.b, ENCODED_NUL.b) end |