Skip to content

Request for from_utf8_lossy-utilizing methods #61

@nullstalgia

Description

@nullstalgia

Howdy!

I'm wanting to use this crate to process ANSI-colored lines from serial port-connected devices. In scenarios with serial devices, it's not uncommon for baud rates to be mismatched. For example, some microcontrollers like the ESP8266 have bootloader output with a static baud rate, and user code can run with any baud after that, even changing during runtime. In those scenarios, I'd much rather have a "best-effort output" rather than writing off the whole input buffer as invalid.

As such, I'm requesting the addition of methods that use String::from_utf8_lossy and potentially simdutf8::compat::from_utf8, replacing damaged/incorrect characters with the Unicode Replacement Character (�).

I haven't seen any other examples of the nom parser being used nor have I had any personal experience with it yet, so I can't instantly spot the best way to implement these.


A couple other things that I might consider raising issues for/attempt myself at a later date, if they're not deemed out of scope are:

  • Methods that return Lines instead of Text. (Presently I have to extract the Line out Text's internal vector to perform wrapping operations on it)
  • Support for the \r + \x1B[K sequence, clearing the contents of the current line (in practice, slicing into the input buffer at a later index).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions