prost icon indicating copy to clipboard operation
prost copied to clipboard

How to decode with from_utf8_lossy?

Open lz1998 opened this issue 3 years ago • 3 comments

"invalid string value: data is not UTF-8 encoded"

Some characters is invalid, but I think it's not important.

Some users may submit invalid utf-8 character, and I can't avoid it.

lz1998 avatar Nov 10 '21 13:11 lz1998

https://github.com/tokio-rs/prost/blob/87cea1d49a4e5df1d4bfd3c26045a444c5f37955/src/encoding.rs#L847

lz1998 avatar Nov 10 '21 14:11 lz1998

If you don't need UTF-8 validation, you can change the type of the field to bytes, which will yield Vec<u8> and utf-8 validation will be skipped. This change is considered wire-compatible per the Protobuf spec.

danburkert avatar Apr 01 '22 19:04 danburkert