Class: InjalidDejice::Decoder

Inherits:
Object
  • Object
show all
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

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.

Parameters:

  • input_string (String)

Returns:

  • (String)


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