Skip to content

Add support for text with emoji #3

@thethtun

Description

@thethtun

When given text include emoji, the app crashed at line 61 (ZawgyiDetector.swift)

let char: Character = Character(UnicodeScalar(inputArray[offset])!)
cp = Int(char.unicodeScalarCodePoint())

Apparently, converting to UnicodeScalar has resulted in crash since initialization is force unwrapped. When input is converted into utf16 array, it counts some emoji as two items. Only the combination of two utf16 results in desired emoji.

I am not sure if this is the correct fix.
Changed code line 48 (ZawgyiDetector.swift)
from this

let inputArray = Array(input.utf16)

to this

let inputArray = Array(input.unicodeScalars)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions