CCBridge // Add convertArabicNumeralsToChinese().

This commit is contained in:
ShikiSuen 2022-08-05 11:29:34 +08:00
parent 424b3791f8
commit d5ff81ed39
1 changed files with 15 additions and 0 deletions

View File

@ -38,6 +38,21 @@ public enum ChineseConverter {
}
}
private static let tableMappingArabicNumeralsToChinese: [String: String] = [
"0": "", "1": "", "2": "", "3": "", "4": "", "5": "", "6": "", "7": "", "8": "", "9": "",
]
///
/// - Parameter target:
public static func convertArabicNumeralsToChinese(target: String) -> String {
var target = target
for key in tableMappingArabicNumeralsToChinese.keys {
guard let result = tableMappingArabicNumeralsToChinese[key] else { continue }
target = target.replacingOccurrences(of: key, with: result)
}
return target
}
/// CrossConvert.
///
/// - Parameter string: Text in Original Script.