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

Add String::from_utf8_lossy and String::from_utf8 #1189

Open
zxch3n opened this issue Nov 2, 2024 · 5 comments
Open

Add String::from_utf8_lossy and String::from_utf8 #1189

zxch3n opened this issue Nov 2, 2024 · 5 comments
Labels

Comments

@zxch3n
Copy link
Contributor

zxch3n commented Nov 2, 2024

No description provided.

@Lampese
Copy link
Collaborator

Lampese commented Nov 3, 2024

Buffer::to_string() or Bytes::to_string?

@zxch3n
Copy link
Contributor Author

zxch3n commented Nov 3, 2024

@Lampese No, IMO they are too ambiguous.

For the Bytes b with the value of [65], what should be the output of b.to_string()?

  • [65]
  • A if we treat it as utf8
  • Error if we treat it as utf16

@chawyehsu
Copy link

chawyehsu commented Nov 7, 2024

It would be better to support bidirectional conversion between UTFs instead of providing only one way interface. I remember this was requested elsewhere before. Edit: #484

@zxch3n
Copy link
Contributor Author

zxch3n commented Nov 8, 2024

@chawyehsu This provides the most intuitive API for converting UTF8 to a built-in String. What's the alternative API design for this?

@suiyunonghen
Copy link

I wrote an implementation:
https://github.com/suiyunonghen/moonvalue/blob/master/src/utf8.mbt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants