Class: InjalidDejice::Decoder
- Inherits:
-
Object
- Object
- InjalidDejice::Decoder
- Defined in:
- lib/injalid_dejice/decoder.rb
Overview
Decodes an US-ASCII (KOI-7-compatible) string to the UTF-8 encoding.
Constant Summary collapse
- OUTPUT_ENCODING =
"UTF-8"
Instance Method Summary collapse
-
#call(input_string) ⇒ String
Encode US-ANSII (KOI-7-compatible) string to the UTF-8.
-
#initialize(unknown_char_rep: DEF_UNKNOWN_CHAR_REP, strict_mode: false) ⇒ Decoder
constructor
A new instance of Decoder.
Constructor Details
#initialize(unknown_char_rep: DEF_UNKNOWN_CHAR_REP, strict_mode: false) ⇒ Decoder
Returns a new instance of Decoder.
10 11 12 13 |
# File 'lib/injalid_dejice/decoder.rb', line 10 def initialize(unknown_char_rep: DEF_UNKNOWN_CHAR_REP, strict_mode: false) @unknown_char_rep = unknown_char_rep @strict_mode = strict_mode end |
Instance Method Details
#call(input_string) ⇒ String
Encode US-ANSII (KOI-7-compatible) string to the UTF-8.
22 23 24 25 26 27 |
# File 'lib/injalid_dejice/decoder.rb', line 22 def call(input_string) @result_string = input_string.dup @start_idx = nil _process_chars(input_string).force_encoding(OUTPUT_ENCODING) end |