Support for encoding/decoding bytes #9
Merged
emmanuelm41 merged 8 commits intomasterfrom Jun 24, 2022
Merged
Conversation
emmanuelm41
requested changes
Jun 23, 2022
Libraries should not have a lock file
emmanuelm41
reviewed
Jun 23, 2022
Comment on lines
209
to
241
| case 3: | ||
| // https://github.com/AssemblyScript/assemblyscript/issues/1609 | ||
| const utf16data: i32[] = []; | ||
| let data: Uint8Array = new Uint8Array(0); | ||
| if (length < 0) { | ||
| while ((length = this.readIndefiniteStringLength(majorType)) >= 0) | ||
| this.appendUtf16Data(utf16data, length); | ||
| } else{ | ||
| this.appendUtf16Data(utf16data, length); | ||
| while ((length = this.readIndefiniteStringLength(majorType)) >= 0) { | ||
| let tmp = new Uint8Array((data.byteLength+length) as u32) | ||
| tmp.set(data) | ||
| tmp.set(this.readArrayBuffer(length as u32), data.byteLength) | ||
| data = tmp | ||
| } | ||
| } else { | ||
| let tmp = new Uint8Array(length as u32) | ||
| tmp.set(this.readArrayBuffer(length as u32)) | ||
| data = tmp | ||
| } | ||
|
|
||
| if(this.handler.stack.length > 0){ | ||
| if (this.handler.peek.isObj) { | ||
| if (this.lastKey == "") { | ||
| this.lastKey = String.fromCharCodes(utf16data) | ||
| this.lastKey = String.UTF8.decode(data.buffer) | ||
| } else { | ||
| this.handler.setString(this.lastKey, String.fromCharCodes(utf16data)) | ||
| this.handler.setString(this.lastKey, String.UTF8.decode(data.buffer)) | ||
| this.lastKey = "" | ||
| } | ||
| } | ||
| if(this.handler.peek.isArr){ | ||
| this.handler.setString(this.lastKey, String.fromCharCodes(utf16data)) | ||
| this.handler.setString(this.lastKey, String.UTF8.decode(data.buffer)) | ||
| this.lastKey = "" | ||
| } | ||
| } | ||
| else | ||
| this.handler.setString("", String.fromCharCodes(utf16data)) | ||
| this.handler.setString("", String.UTF8.decode(data.buffer)) | ||
|
|
||
| return |
Member
There was a problem hiding this comment.
Is it possible that we loose utf16 support with this implementation?
emmanuelm41
approved these changes
Jun 23, 2022
Member
emmanuelm41
left a comment
There was a problem hiding this comment.
Really nice features added! Great work :D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 zboto Link