Class: InjalidDejice::Encoder
- Inherits:
-
Object
- Object
- InjalidDejice::Encoder
- Defined in:
- lib/injalid_dejice/encoder.rb
Overview
Encodes a UTF-8 string to the KOI-7 encoding.
Constant Summary collapse
- OUTPUT_ENCODING =
"US-ASCII"
Instance Method Summary collapse
-
#call(input_string) ⇒ String
Encode ‘input_string’ to the KOI-7 encoding.
Instance Method Details
#call(input_string) ⇒ String
Encode ‘input_string’ to the KOI-7 encoding.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/injalid_dejice/encoder.rb', line 19 def call(input_string) non_latin_indexes = _search_non_latin_indexes(input_string) result = if non_latin_indexes.empty? # No non-Latin characters were found, so no futher action needed. input_string.dup else _insert_shift_chars( _handle_replacements(input_string), non_latin_indexes ) end result.force_encoding(OUTPUT_ENCODING) end |