Skip to content

Use byte arrays instead of strings for text as they are not UTF-8 encoded #6

@v1993

Description

@v1993

First of all, thank you so much for this library!

I think that SendType should use &[u8] instead of &str for text. Fundamentally, Rust strings are UTF-8, and text you're sending to a display will be in a custom 8-bit encoding (possibly with multiple pages, controlled separately), most definitely not in UTF-8. This leads to very real issues when I want to use my display's additional symbols but Rust prevents me from putting the corresponding literals into strings and iterates over them incorrectly even if I force it to with a bit of unsafe transmutations. Fortunately, it's possible to work around this by calling send manually, but that's what write is supposed to help with in the first place.

If preserving backward compatibility is vital, a new enumeration value in SendType, e.g. Binary could be added. However, I'd say that the current API is technically wrong, and migration is likely to be rather simple anyways.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions