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

support rendering of errors if a file is only partially encoded in UTF-8 #246

Open
fogti opened this issue Jun 17, 2020 · 3 comments
Open

Comments

@fogti
Copy link

fogti commented Jun 17, 2020

I want to support the use case that a file contains both utf-8 encoded commands and binary data, such that if an error occures, it is only important that the text selected via labels is valid utf-8, but doesn't require that the whole file is utf-8. As line numbers and such don't make much sense in that scenario, it would be good to print the raw byte positions instead of line numbers. An optional interaction with the bstr crate (the bstr::BStr struct has a nice Debug implementation) might be useful. If the text selected via labels contains invalid utf-8, it should be printed as hex or something similiar, at least, it shouldn't fail.

@brendanzab
Copy link
Owner

I wonder how much this is related to #187? 🤔

@brendanzab
Copy link
Owner

It might be helpful to give a mock-up of what you want the output to look like as well! Might be easier for me to visualise that way.

@fogti
Copy link
Author

fogti commented Jun 18, 2020

I think there are multiple possibilities:

  • (a) only support printing if the snippet does only contain utf-8 (probably easier, but less useful)
  • (b) escape non-utf8 characters (more difficult, because the calculation of arrows and such gets more difficult)

I currently don't really know how the output should look like, but it should at least provide the following informations:

  • file name
  • line number / column if applicable (e.g. no non-utf8 stuff before the labels)
  • raw byte position / span (always if the given slice contains non-UTF8 data)
  • error messages
  • the corresponding snippet including arrows/label pointers...

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