Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

International Number Formats

0.00/5 (No votes)
30 Apr 2010 1  
This article explains different number formatting based on locale

Introduction

Recently, I was surprised to discover that in addition to the standard US number format (1,234.67) and some European country format (1.234,56 and 1 234,56), there are other number formats. So I wrote a function that lists all of the number formats out there in VB.NET.

Public Function GetCultureSelect() As String
 Dim oHashtable As New Hashtable
 For Each oCultureInfo As System.Globalization.CultureInfo _
	In System.Globalization.CultureInfo.GetCultures_
	(System.Globalization.CultureTypes.AllCultures)
  Dim sKey As String = oCultureInfo.Name
  Dim sName As String = oCultureInfo.EnglishName
  Try
   Dim oNumberFormat As System.Globalization.NumberFormatInfo = oCultureInfo.NumberFormat
   Dim s As String = oNumberFormat.CurrencyDecimalSeparator
   Dim sFormat As String = "1" & oNumberFormat.CurrencyGroupSeparator & "234" & _
	oNumberFormat.CurrencyDecimalSeparator & "56"
   If oHashtable.ContainsKey(sFormat) = False Then
    oHashtable.Add(sFormat, sKey & " - " & sName)
   Else
    oHashtable(sFormat) += "<br>" & sKey & " - " & sName
   End If
  Catch ex As Exception
  End Try
 Next
 Dim sb As New System.Text.StringBuilder()
 sb.Append("<table border=1>" & vbCrLf)
 sb.Append("<tr><th>Format</th><th>Country</th></tr>" & vbCrLf)
 For Each oEntry As DictionaryEntry In oHashtable
  sb.Append("<tr><td valign=top>" & oEntry.Key & "</td><td>" & _
	oEntry.Value & "</td></tr>" & vbCrLf)
 Next
 sb.Append("</table>")
 Return sb.ToString()
End Function 

Here is the table this VB.NET function returns:

Format Country
1,234.56 - Invariant Language (Invariant Country)
ar-SA - Arabic (Saudi Arabia)
zh-TW - Chinese (Taiwan)
en-US - English (United States)
he-IL - Hebrew (Israel)
ja-JP - Japanese (Japan)
ko-KR - Korean (Korea)
th-TH - Thai (Thailand)
ur-PK - Urdu (Islamic Republic of Pakistan)
hy-AM - Armenian (Armenia)
af-ZA - Afrikaans (South Africa)
hi-IN - Hindi (India)
sw-KE - Kiswahili (Kenya)
pa-IN - Punjabi (India)
gu-IN - Gujarati (India)
ta-IN - Tamil (India)
te-IN - Telugu (India)
kn-IN - Kannada (India)
mr-IN - Marathi (India)
sa-IN - Sanskrit (India)
kok-IN - Konkani (India)
syr-SY - Syriac (Syria)
dv-MV - Divehi (Maldives)
ar-IQ - Arabic (Iraq)
zh-CN - Chinese (People's Republic of China)
en-GB - English (United Kingdom)
es-MX - Spanish (Mexico)
ar-EG - Arabic (Egypt)
zh-HK - Chinese (Hong Kong S.A.R.)
en-AU - English (Australia)
ar-LY - Arabic (Libya)
zh-SG - Chinese (Singapore)
en-CA - English (Canada)
es-GT - Spanish (Guatemala)
ar-DZ - Arabic (Algeria)
zh-MO - Chinese (Macao S.A.R.)
en-NZ - English (New Zealand)
ar-MA - Arabic (Morocco)
en-IE - English (Ireland)
es-PA - Spanish (Panama)
ar-TN - Arabic (Tunisia)
en-ZA - English (South Africa)
es-DO - Spanish (Dominican Republic)
ar-OM - Arabic (Oman)
en-JM - English (Jamaica)
ar-YE - Arabic (Yemen)
en-029 - English (Caribbean)
ar-SY - Arabic (Syria)
en-BZ - English (Belize)
es-PE - Spanish (Peru)
ar-JO - Arabic (Jordan)
en-TT - English (Trinidad and Tobago)
ar-LB - Arabic (Lebanon)
en-ZW - English (Zimbabwe)
ar-KW - Arabic (Kuwait)
en-PH - English (Republic of the Philippines)
ar-AE - Arabic (U.A.E.)
ar-BH - Arabic (Bahrain)
ar-QA - Arabic (Qatar)
es-SV - Spanish (El Salvador)
es-HN - Spanish (Honduras)
es-NI - Spanish (Nicaragua)
es-PR - Spanish (Puerto Rico)
zu-ZA - Zulu (South Africa)
xh-ZA - Xhosa (South Africa)
tn-ZA - Tswana (South Africa)
quz-PE - Quechua (Peru)
cy-GB - Welsh (United Kingdom)
fil-PH - Filipino (Philippines)
iu-Latn-CA - Inuktitut (Latin) (Canada)
mi-NZ - Maori (New Zealand)
ga-IE - Irish (Ireland)
moh-CA - Mohawk (Canada)
ns-ZA - Northern Sotho (South Africa)
mt-MT - Maltese (Malta)
1.234,56 ca-ES - Catalan (Catalan)
da-DK - Danish (Denmark)
de-DE - German (Germany)
el-GR - Greek (Greece)
is-IS - Icelandic (Iceland)
it-IT - Italian (Italy)
nl-NL - Dutch (Netherlands)
pt-BR - Portuguese (Brazil)
ro-RO - Romanian (Romania)
hr-HR - Croatian (Croatia)
sq-AL - Albanian (Albania)
sv-SE - Swedish (Sweden)
tr-TR - Turkish (Turkey)
id-ID - Indonesian (Indonesia)
sl-SI - Slovenian (Slovenia)
lt-LT - Lithuanian (Lithuania)
vi-VN - Vietnamese (Vietnam)
eu-ES - Basque (Basque)
mk-MK - Macedonian (Former Yugoslav Republic of Macedonia)
fo-FO - Faroese (Faroe Islands)
ms-MY - Malay (Malaysia)
gl-ES - Galician (Galician)
fr-BE - French (Belgium)
nl-BE - Dutch (Belgium)
pt-PT - Portuguese (Portugal)
sr-Latn-CS - Serbian (Latin, Serbia)
ms-BN - Malay (Brunei Darussalam)
de-AT - German (Austria)
es-ES - Spanish (Spain)
sr-Cyrl-CS - Serbian (Cyrillic, Serbia)
de-LU - German (Luxembourg)
es-CR - Spanish (Costa Rica)
es-VE - Spanish (Venezuela)
es-CO - Spanish (Colombia)
es-AR - Spanish (Argentina)
es-EC - Spanish (Ecuador)
es-CL - Spanish (Chile)
es-UY - Spanish (Uruguay)
es-PY - Spanish (Paraguay)
es-BO - Spanish (Bolivia)
sr-Cyrl-BA - Serbian (Cyrillic) (Bosnia and Herzegovina)
fy-NL - Frisian (Netherlands)
se-SE - Sami (Northern) (Sweden)
sma-SE - Sami (Southern) (Sweden)
hr-BA - Croatian (Bosnia and Herzegovina)
bs-Latn-BA - Bosnian (Bosnia and Herzegovina)
bs-Cyrl-BA - Bosnian (Cyrillic) (Bosnia and Herzegovina)
arn-CL - Mapudungun (Chile)
quz-EC - Quechua (Ecuador)
sr-Latn-BA - Serbian (Latin) (Bosnia and Herzegovina)
smj-SE - Sami (Lule) (Sweden)
quz-BO - Quechua (Bolivia)
1'234.56 de-CH - German (Switzerland)
it-CH - Italian (Switzerland)
fr-CH - French (Switzerland)
de-LI - German (Liechtenstein)
rm-CH - Romansh (Switzerland)
1 234,56 bg-BG - Bulgarian (Bulgaria)
cs-CZ - Czech (Czech Republic)
fi-FI - Finnish (Finland)
fr-FR - French (France)
hu-HU - Hungarian (Hungary)
nb-NO - Norwegian, Bokmål (Norway)
pl-PL - Polish (Poland)
ru-RU - Russian (Russia)
sk-SK - Slovak (Slovakia)
uk-UA - Ukrainian (Ukraine)
be-BY - Belarusian (Belarus)
lv-LV - Latvian (Latvia)
az-Latn-AZ - Azeri (Latin, Azerbaijan)
ka-GE - Georgian (Georgia)
uz-Latn-UZ - Uzbek (Latin, Uzbekistan)
tt-RU - Tatar (Russia)
mn-MN - Mongolian (Cyrillic, Mongolia)
nn-NO - Norwegian, Nynorsk (Norway)
sv-FI - Swedish (Finland)
az-Cyrl-AZ - Azeri (Cyrillic, Azerbaijan)
uz-Cyrl-UZ - Uzbek (Cyrillic, Uzbekistan)
fr-CA - French (Canada)
fr-LU - French (Luxembourg)
fr-MC - French (Principality of Monaco)
sma-NO - Sami (Southern) (Norway)
smn-FI - Sami (Inari) (Finland)
se-FI - Sami (Northern) (Finland)
sms-FI - Sami (Skolt) (Finland)
smj-NO - Sami (Lule) (Norway)
lb-LU - Luxembourgish (Luxembourg)
se-NO - Sami (Northern) (Norway)
1,234/56 fa-IR - Persian (Iran)
1 234-56 kk-KZ - Kazakh (Kazakhstan)
ky-KG - Kyrgyz (Kyrgyzstan)
1 234.56 et-EE - Estonian (Estonia)

I hope someone might find this information useful.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here