Class: ZeroWidthCharacterEncoder
- Inherits:
-
Object
- Object
- ZeroWidthCharacterEncoder
- Defined in:
- lib/tolgee_liquid/zero_width_character_encoder.rb
Overview
An string encoder that will transform original message to invisible ASCII characters. See the detail in: tolgee.io/blog/2021/12/17/invisible-characters-for-better-localization
Constant Summary collapse
- INVISIBLE_CHARACTERS =
["\u200C", "\u200D"].freeze
Instance Method Summary collapse
Instance Method Details
#execute(text) ⇒ Object
8 9 10 11 12 |
# File 'lib/tolgee_liquid/zero_width_character_encoder.rb', line 8 def execute(text) bytes = text.bytes binary = bytes.map { |byte| to_binary_with_extra_non_join_character(byte) }.join to_invisible_string(binary) end |