gr2m / initials

extract initials from and add initials to names
https://gr2m.github.io/initials
MIT License
44 stars 14 forks source link

Can't handle emoji in names #30

Closed Froelund closed 5 years ago

Froelund commented 7 years ago

Emojis ends up as an illegal character:

t.equal(initials('John ๐Ÿface'), 'J๐Ÿ', 'John ๐Ÿface (j๐Ÿ) โ˜› j๐Ÿ');

โœ– John ๐Ÿface (j๐Ÿ) โ˜› j๐Ÿ
    --------------------------
      operator: equal
      expected: 'J๐Ÿ'
      actual:   'J๏ฟฝ'
      stack: |-
gr2m commented 7 years ago

thatโ€™s a new one :) How would you fix it?

Froelund commented 7 years ago

Yes! The times they are a-changin' ๐Ÿ‘ I don't know what the exact issue is, but I suspect something with number of bytes taken from the lastname doesn't match the length of the first character(emoji).

gr2m commented 7 years ago

So I see two ways addressing this

  1. Mention in the README that initials doesnโ€™t handle emojis well
  2. Implement some good handling of emojis that I donโ€™t see right now :)
gr2m commented 6 years ago

@Froelund did you come up with a workaround?