mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[BUG] [stdlib] Fix `String.format()` to use explicit byte indexing and not assume `String.__getitem__` indexes directly to byte offset.

Open martinvuyk opened this issue 7 months ago • 0 comments

Bug description

Fix String.format() to use explicit byte indexing and not assume String.__getitem__ indexes directly to byte offset.

Python's String indexes by unicode codepoints (UTF-32) our String implementation currently uses UTF-8 and it's __getitem__ returns by byte offset. We need to be compliant with Python's indexing using unicode codepoints and String.format() needs to be fixed.

This is related to PR #3295 and issue #3246

@rd4com I saw it's code you commited, do you wanna take this or should I ?

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

System information

- What OS did you do install Mojo on ?
- Provide version information for Mojo by pasting the output of `mojo -v`
- Provide Modular CLI version by pasting the output of `modular -v`

martinvuyk avatar Jul 23 '24 19:07 martinvuyk