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

"%2s" does not add left-padding when given a unicode character #2426

Closed
postmodern opened this issue Aug 20, 2021 · 2 comments
Closed

"%2s" does not add left-padding when given a unicode character #2426

postmodern opened this issue Aug 20, 2021 · 2 comments
Assignees
Milestone

Comments

@postmodern
Copy link

It appears that when formatting a unicode characters within a %2s format string, the raw byte length of the unicode String is used instead of the character length.

Expected Behavior

("%2s" % "☃").length
# => 2

Actual Behavior

("%2s" % "☃").length
# => 1

Version Info

$ truffleruby -v
truffleruby 21.2.0.1, like ruby 2.7.3, GraalVM CE Native [x86_64-linux]
@postmodern postmodern changed the title %2s does not add left-padding for unicode characters "%2s" does not add left-padding for unicode characters Aug 20, 2021
@postmodern postmodern changed the title "%2s" does not add left-padding for unicode characters "%2s" does not add left-padding when given a unicode character Aug 20, 2021
@eregon
Copy link
Member

eregon commented Aug 20, 2021

@aardvark179 Could you take a look at this one? (can be after the rb_sprintf changes)

@aardvark179
Copy link
Contributor

This was actually fixed as part of the rb_sprintf work I believe. It certainly appears to be producing the correct results now.

@eregon eregon added this to the 22.0.0 milestone Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants