Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASCII encoding issue #6

Open
Timmmm opened this issue Dec 20, 2024 · 0 comments
Open

ASCII encoding issue #6

Timmmm opened this issue Dec 20, 2024 · 0 comments

Comments

@Timmmm
Copy link

Timmmm commented Dec 20, 2024

We somehow got some non-ASCII text into our Sail code:

The trap handler function address is obtained from the current privilege mode’s

(note the weird ' in mode’s)

If you compile this to JSON using sail, it writes it out as-is (i.e. with UTF-8) encoding. However Ruby idiotically defaults to ASCII when reading files, and it throws an error:

/var/lib/gems/3.0.0/gems/json-2.9.0/lib/json/common.rb:221:in `encode': asciidoctor: FAILED: /build/src/riscv-cheri.adoc: Failed to load AsciiDoc document - "\\xE2" on US-ASCII (Encoding::InvalidByteSequenceError)
        from /var/lib/gems/3.0.0/gems/json-2.9.0/lib/json/common.rb:221:in `parse'
        from /var/lib/gems/3.0.0/gems/json-2.9.0/lib/json/common.rb:221:in `parse'
        from /var/lib/gems/3.0.0/gems/asciidoctor-sail-0.2/lib/asciidoctor-sail/sources.rb:18:in `register'
        from /var/lib/gems/3.0.0/gems/asciidoctor-sail-0.2/lib/asciidoctor-sail/macros.rb:15:in `get_sourcemap'
        from /var/lib/gems/3.0.0/gems/asciidoctor-sail-0.2/lib/asciidoctor-sail/macros.rb:133:in `get_source'
        from /var/lib/gems/3.0.0/gems/asciidoctor-sail-0.2/lib/asciidoctor-sail/macros.rb:210:in `process'

According to ChatGPT this should work:

file = File.read(sourcemap_path, encoding: 'UTF-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant