-
Couldn't load subscription status.
- Fork 142
feat: encoding/utf16 #2743
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
feat: encoding/utf16 #2743
Conversation
Pull Request Test Coverage Report for Build 1636Details
💛 - Coveralls |
encoding/utf16le/pkg.generated.mbti
Outdated
| fn decode_lossy(BytesView, ignore_bom? : Bool) -> String | ||
|
|
||
| fn encode(StringView, bom? : Bool) -> Bytes | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn encode(StringView, bom? : Bool, endianness : Endian = Little) -> Bytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely double the code size, introduce unnecessary branching.
142c3d4 to
5a46252
Compare
37a44a6 to
0bd00a1
Compare
| #deprecated("Use `@encoding/utf16le.encode` instead") | ||
| #coverage.skip | ||
| pub fn StringView::to_bytes(self : StringView) -> Bytes { | ||
| let array = FixedArray::make(self.length() * 2, Byte::default()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in most cases, this is not what we need, encode is mostly what we need
0bd00a1 to
ef81bec
Compare
Potential buffer overflow in big-endian decode when converting surrogate pairsCategory Inefficient byte-by-byte copying in big-endian encodingCategory Duplicated BOM handling and validation logic between decode functionsCategory |
This PR adds UTF16 encoding/decoding, and deprecate any other
StringtoBytesconversions as they are misleading.