mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various UI fixes
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
import Foundation
|
||||
|
||||
public func convertToArabicNumeralString(_ string: String) -> String {
|
||||
public enum ArabicNumeralStringType {
|
||||
case western
|
||||
case eastern
|
||||
}
|
||||
|
||||
public func normalizeArabicNumeralString(_ string: String, type: ArabicNumeralStringType) -> String {
|
||||
var string = string
|
||||
let arabicNumbers = ["٠": "0", "١": "1", "٢": "2", "٣": "3", "٤": "4", "٥": "5", "٦": "6", "٧": "7", "٨": "8", "٩": "9"]
|
||||
for (arabic, generic) in arabicNumbers {
|
||||
string = string.replacingOccurrences(of: generic, with: arabic)
|
||||
let numerals = ["٠": "0", "١": "1", "٢": "2", "٣": "3", "٤": "4", "٥": "5", "٦": "6", "٧": "7", "٨": "8", "٩": "9"]
|
||||
for (easternNumeral, westernNumeral) in numerals {
|
||||
switch type {
|
||||
case .western:
|
||||
string = string.replacingOccurrences(of: easternNumeral, with: westernNumeral)
|
||||
case .eastern:
|
||||
string = string.replacingOccurrences(of: westernNumeral, with: easternNumeral)
|
||||
}
|
||||
|
||||
}
|
||||
return string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user