Skip to content

Fix the truncation of unicode strings#108

Merged
davidchin merged 1 commit intobigcommerce:masterfrom
davidchin:unicode_substr
Feb 20, 2017
Merged

Fix the truncation of unicode strings#108
davidchin merged 1 commit intobigcommerce:masterfrom
davidchin:unicode_substr

Conversation

@davidchin
Copy link
Copy Markdown
Contributor

What?

  • Added a handlebars helper to truncate a string #106 added a truncation helper. It uses String.prototype.substring to truncate strings. However, the native function doesn't handle unicode characters properly. So, if you call the truncate helper on strings containing unicode characters (some non-English characters or emoji), you won't get what you expect.
  • To save time, I decided to use a third party library called stringz. It has MIT license, so we should be good to use.

Why?

  • This is necessary because we need to support multiple languages in Stencil.

Testing / Proof

  • Unit

@bigcommerce/checkout @bigcommerce/stencil-team

Copy link
Copy Markdown
Contributor

@mcampa mcampa left a comment

Choose a reason for hiding this comment

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

Awesome 👍

@davidchin davidchin merged commit 3fd5974 into bigcommerce:master Feb 20, 2017
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