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

Uft8Error when reciving #364

Open
KilroyWasHere-cs-j opened this issue Jan 26, 2023 · 3 comments
Open

Uft8Error when reciving #364

KilroyWasHere-cs-j opened this issue Jan 26, 2023 · 3 comments

Comments

@KilroyWasHere-cs-j
Copy link

str::from_utf8(&data[1]).unwrap() throws Result::unwrap() on an Err value: Utf8Error { valid_up_to: 0, error_len: Some(1) }

New to rust what's the fix.

@magnificus
Copy link

I got the same error when a user was sending non-unicode characters and I tried to stringify, solution in my case was to use from_utf8_lossy (which obviously will lose some information though).

String::from_utf8_lossy(&topic).to_string();

@jtacoma
Copy link

jtacoma commented Apr 28, 2024

I think this issue can be closed now: @magnificus responded to the problem @KilroyWasHere-cs-j was dealing with, and the problem was just that data[1] wasn't valid UTF-8, which is not an issue with rust-zmq.

@KilroyWasHere-cs-j
Copy link
Author

Yep correct. No need to leave this open.

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

3 participants