Skip to content

Make wtf-8 and wtf-16 handling more uniform - #22

Merged
wingo merged 1 commit into
mainfrom
uniformity
Jun 22, 2022
Merged

wingo merged 1 commit into
mainfrom
uniformity

Conversation

@wingo

@wingo wingo commented Jun 22, 2022

Copy link
Copy Markdown
Collaborator
  • string.new_wtf8 takes a wtf8_policy immediate, to allow for U+FFFD
    replacement of any invalid WTF-8 subsequence.
  • Remove string.measure_utf8, replacing with string.measure_wtf8 with a
    wtf8_policy immediate.
  • string.measure_wtf16 returns length in code units, not bytes.
  • Specify little-endian for string.encode_wtf16.

 * string.new_wtf8 takes a wtf8_policy immediate, to allow for U+FFFD
   replacement of any invalid WTF-8 subsequence.
 * Remove string.measure_utf8, replacing with string.measure_wtf8 with a
   wtf8_policy immediate.
 * string.measure_wtf16 returns length in code units, not bytes.
 * Specify little-endian for string.encode_wtf16.

@jakobkummerow jakobkummerow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


instr ::= ...
| 0xfb 0x80 $mem:u32 ⇒ string.new_wtf8 $mem
| 0xfb 0x80 $mem:u32 $policy:u32 ⇒ string.new_wtf8 $mem $policy

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could limit the $policy immediate to one byte as u8. Probably doesn't make a difference in practice.

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

Successfully merging this pull request may close these issues.

2 participants