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

Filter size counts number of bytes instead of number of characters #100

Open
2 tasks done
jamslinger opened this issue Oct 19, 2024 · 0 comments
Open
2 tasks done

Comments

@jamslinger
Copy link
Contributor

Checklist

  • I have searched the issue list
  • I have tested my example against Shopify Liquid. (This isn't necessary if the actual behavior is a panic, or an error for which IsTemplateError returns false.)

Expected Behavior

Return the number of characters instead of the number of bytes when using the size filter on a string.

Actual Behavior

The current implementation returns the number of bytes when using size on a string.

Detailed Description

Shopify's liquid counts number of characters instead of number of bytes when using the size filter on a string, e.g.:

{{ "Straße" | size }} // -> 6, even though "ß" is encoded as a sequence of two bytes, so `len("Straße") = 7`. 

Possible Solution

Return the rune count instead of the number of bytes when using size on a string.

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

No branches or pull requests

1 participant