GetStream / Streamoji

:godmode: Custom emoji rendering library for iOS apps with support for GIF & still images - plug-in extension for UITextView - performance, cache ✅ - Made with 💘 by @GetStream
https://getstream.io/
MIT License
253 stars 15 forks source link

Unrepresentable unicode characters cannot be used as : shortcode: #1

Closed LionChen-WORK closed 4 years ago

LionChen-WORK commented 4 years ago

This does not work:

let shortCodes: [String: EmojiSource] = [
    "\u{F0000}": .imageAsset("Image-F0000"),
]

This is probably a rare use case, but I am trying to use Streamoji to replace some '�' that might occur in an app.

cardoso commented 4 years ago

Hi @LionChen-WORK ,

Thanks for opening the issue. Do you need ":�:" to be replaced with an emoji or only "�" ?

LionChen-WORK commented 4 years ago

Do you need ":�:" to be replaced with an emoji or only "�" ?

Sorry for not being clear. I am trying to get ":�:" be replaced.

Here is an example:

class ViewController: UIViewController {

    private let emojis: [String: EmojiSource] = [
        "c": .character("😄"),
        "\u{F0000}": .character("❤️"),
    ]

    @IBOutlet weak var textView: UITextView!

    override func viewDidLoad() {
        super.viewDidLoad()

        textView.text = """
            Unpresentable character: :\u{F0000}:
            Control group: :c:
            """
        textView.configureEmojis(emojis)
    }

}

And this is the result:

streamoji-issue-1-example-1

cardoso commented 4 years ago

@LionChen-WORK have you tried pasting the character directly in the source code?

private let emojis: [String: EmojiSource] = [
    "c": .character("😄"),
    "�": .character("❤️"),
]
cardoso commented 4 years ago

@LionChen-WORK I just pushed version 0.1.8 which should fix your issue. I tweaked the RegEx to find unicode characters inside the shortcode. Thanks a lot for opening this issue!

LionChen-WORK commented 4 years ago

have you tried pasting the character directly in the source code?

Have not tried this. But I was hoping that I could show different images for different unicodes.

I just pushed version 0.1.8 which should fix your issue. I tweaked the RegEx to find unicode characters inside the shortcode. Thanks a lot for opening this issue!

Great work! 😀