I need a way to convert a string that contains a literal string representing a hexadecimal value into a Character corresponding to that particular hexadecimal value.
Another simple way based on ICU transforms:
extension String { func transformingFromHex() -> String? { return "\(self);".applyingTransform(.toXMLHex, reverse: true) } }
Usage:
"2C".transformingFromHex()
Results in: ,
,