Files
GLEGram-iOS/submodules/TelegramStringFormatting/Sources/NumberFormat.swift
T
Leeksov 4647310322 GLEGram 12.5 — Initial public release
Based on Swiftgram 12.5 (Telegram iOS 12.5).
All GLEGram features ported and organized in GLEGram/ folder.

Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass,
Font Replacement, Fake Profile, Chat Export, Plugin System, and more.

See CHANGELOG_12.5.md for full details.
2026-04-06 09:48:12 +03:00

41 lines
1.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
public enum ArabicNumeralStringType {
case western
case arabic
case persian
}
public func normalizeArabicNumeralString(_ string: String, type: ArabicNumeralStringType) -> String {
var string = string
let numerals = [
("0", "٠", "۰"),
("1", "١", "۱"),
("2", "٢", "۲"),
("3", "٣", "۳"),
("4", "٤", "۴"),
("5", "٥", "۵"),
("6", "٦", "۶"),
("7", "٧", "۷"),
("8", "٨", "۸"),
("9", "٩", "۹"),
(",", "٫", "٫")
]
for (western, arabic, persian) in numerals {
switch type {
case .western:
string = string.replacingOccurrences(of: arabic, with: western)
string = string.replacingOccurrences(of: persian, with: western)
case .arabic:
string = string.replacingOccurrences(of: western, with: arabic)
string = string.replacingOccurrences(of: persian, with: arabic)
case .persian:
string = string.replacingOccurrences(of: western, with: persian)
string = string.replacingOccurrences(of: arabic, with: persian)
}
}
return string
}