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

issues when displaying unicode #128

Open
nevakrien opened this issue Aug 27, 2024 · 1 comment
Open

issues when displaying unicode #128

nevakrien opened this issue Aug 27, 2024 · 1 comment

Comments

@nevakrien
Copy link

so for version 4 and above when I print pretrty much any error that contains something like this 🏳️‍⚧️
anywhere in the source it would just cut it. version 3 has weird formating things on the colors but otherwise works

specifcly I ran this

// Function to create a report for UnclosedString
fn handle_unclosed_string<'a>(span: LocatedSpan<&'a str>, ch: char, source: &'a str) -> Report<'a, Range> {
let (line, line_range, _) = get_line_info(source, span.location_offset());
let byte_offset = span.location_offset();
let span_len = span.fragment().len();

Report::build(ReportKind::Error, (), byte_offset)
    .with_config(ariadne::Config::default().with_char_set(CharSet::Unicode))
    .with_message("Unclosed string error")
    .with_label(
        Label::new(byte_offset..byte_offset + span_len)
            .with_message(format!("Expected closing '\\{}'", ch))
            .with_color(Color::Red),
    )
    .with_label(
        Label::new(line_range)
            .with_message(line)
            .with_color(Color::White),
    )
    .finish()

}

and it would work fine on most texts but fail on something like ", 丐, 丑 \n\nmore::stuff\n\n" unclosed string"
by printing just Error: Unclosed string error

@zesterer
Copy link
Owner

By default, Ariadne uses character offsets for spans. This can be configured though, the docs for Config will have more information.

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

2 participants