Class: RosettAi::I18n::Utf8Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/i18n/utf8_checker.rb

Overview

Validates that the runtime environment supports UTF-8 encoding.

Called early in CLI startup to fail fast with a clear error rather than producing garbled output.

Class Method Summary collapse

Class Method Details

.check!void

This method returns an undefined value.

Exits with an error if the runtime is not UTF-8.



17
18
19
20
21
22
23
# File 'lib/rosett_ai/i18n/utf8_checker.rb', line 17

def self.check!
  return if utf8_environment?

  warn "rai requires a UTF-8 terminal. Current: #{Encoding.default_external}"
  warn 'Set: export LANG=en_US.UTF-8'
  exit 1
end

.utf8_environment?Boolean

Whether the default external encoding is UTF-8.

Returns:

  • (Boolean)


28
29
30
# File 'lib/rosett_ai/i18n/utf8_checker.rb', line 28

def self.utf8_environment?
  Encoding.default_external == Encoding::UTF_8
end