Created
October 24, 2018 11:08
-
-
Save jerrypm/b7236cc2dd79271ca58fee16ca10274f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class EmojiReadViewController: UIViewController { | |
| @IBOutlet weak var labelAndroidToIOS: UILabel! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| var dataFromAndroid = "😊😁 loream ipsum qeqeura dafult" | |
| let replace2 = dataAndroid2.replacingOccurrences(of: "[\\&#(.*?)\\;]", with: " ", options: .regularExpression) | |
| let array = replace2.components(separatedBy: " ") | |
| print(array) | |
| var boldKey33: [String] = [] | |
| for item in array { | |
| if isStringAnInt(string: item) { | |
| let dataResult = String(Int(item)!, radix: 16) | |
| let str = String(UnicodeScalar(Int(dataResult, radix: 16)!)!) | |
| boldKey33.append(str) | |
| } else { | |
| print("data not a Int \(item)") | |
| } | |
| } | |
| print(boldKey33.description) | |
| while let itemEnd = dataAndroid2.range(of: "\\&#(.*?)\\;", options: .regularExpression, range: nil, locale: nil) { | |
| dataAndroid2.replaceSubrange(itemEnd, with: boldKey33.removeFirst()) | |
| } | |
| labelAndroidToIOS.text = dataAndroid2 | |
| print("Emoji android(DEC) to IOS(HEX): \(dataAndroid2)") | |
| // Important for check data Int in string | |
| func isStringAnInt(string: String) -> Bool { | |
| return Int(string) != nil | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment