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

Remove invisible U+200E unicode character from yabai query #406

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

mrala
Copy link
Contributor

@mrala mrala commented Jun 24, 2024

Description

If an app has an invisible U+200E character, it will not match the app name defined in app-icons.js.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Validated app names are dropping the U+200E character without affecting other unicode characters.
❯ queryTitle=$(yabai -m query --windows --space 1 | jq '.[].app')
❯ echo $queryTitle
"‎WhatsApp"

# get the ASCII value of the unicode character
❯ echo $queryTitle | hexdump -C
00000000  22 e2 80 8e 57 68 61 74  73 41 70 70 22 0a        |"...WhatsApp".|
0000000e

# compare to expected string without unicode character
❯ echo \"WhatsApp\" | hexdump -C
00000000  22 57 68 61 74 73 41 70  70 22 0a                 |"WhatsApp".|
0000000b


❯ echo $queryTitle
"‎WhatsApp"

# get number of bytes with string that contains hidden unicode character
❯ echo $queryTitle | wc -c
      14

# remove UTF-8 hex (e2 80 8e)
❯ echo $queryTitle | sed "s/\xe2\x80\x8e//g" | wc -c
      11
# compare number of bytes to string without unicode character
❯ echo \"WhatsApp\" | wc -c
      11


# does not affect other unicode characters, test with Chinese name for Finder
❯ echo $'\U8BBF'$'\U8FBE'
访达
❯ echo $'\U8BBF'$'\U8FBE' | wc -c
       7
❯ echo $'\U8BBF'$'\U8FBE' | sed "s/\xe2\x80\x8e//g"
访达
❯ echo $'\U8BBF'$'\U8FBE' | sed "s/\xe2\x80\x8e//g" | wc -c
       7

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Changes to make to the documentation

n/a

@mrala mrala changed the title Remove non-printable ASCII characters from yabai query Remove invisible U+200E unicode character from yabai query Jun 24, 2024
@Jean-Tinland Jean-Tinland merged commit 4c5ba7f into Jean-Tinland:master Jul 2, 2024
@Jean-Tinland
Copy link
Owner

Thank you for that! I appreciate your contributions :)

@mrala mrala deleted the fix-unicode-chars branch July 3, 2024 05:43
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.

WhatsApp icon not being used
2 participants