Module: Ibex::Frontend::SourceEncoding

Defined in:
lib/ibex/frontend/source_span.rb

Overview

Normalizes grammar source without changing its bytes.

Class Method Summary collapse

Class Method Details

.validated_utf8(source, file) ⇒ Object

Raises:



8
9
10
11
12
13
# File 'lib/ibex/frontend/source_span.rb', line 8

def self.validated_utf8(source, file)
  validated = source.dup.force_encoding(Encoding::UTF_8)
  raise Ibex::Error, "#{file}: input must be valid UTF-8" unless validated.valid_encoding?

  validated.freeze
end