Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string ToNativeDigits(this string text, CultureInfo culture = null)
- {
- culture = culture ?? CultureInfo.CurrentCulture;
- var nativeDigits = culture.NumberFormat.NativeDigits;
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < text.Length; i++)
- {
- char c = text[i];
- if (c >= '0' && c <= '9')
- {
- int v = (int)(c - '0');
- string nc = nativeDigits[v];
- sb.Append(nc);
- }
- else
- {
- sb.Append(c);
- }
- }
- return sb.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement