Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::Locale Class Reference

A locale instance represents the cultural data used to convert data to string in manner appropriate to the language and country. More...

#include <vcf/FoundationKit/Locales.h>

Inheritance diagram for VCF::Locale:

VCF::Object List of all members.

Public Types

enum  CountryCodes {
  ccUndefined = 0, ccAfghanistan = 'AF', ccAlbania = 'AL', ccAlgeria = 'DZ',
  ccAmericanSamoa = 'AS', ccAndorra = 'AD', ccAngola = 'AO', ccAnguilla = 'AI',
  ccAntarctica = 'AQ', ccAntiguaAndBarbuda = 'AG', ccArgentina = 'AR', ccArmenia = 'AM',
  ccAruba = 'AW', ccAustralia = 'AU', ccAustria = 'AT', ccAzerbaijan = 'AZ',
  ccBahamas = 'BS', ccBahrain = 'BH', ccBangladesh = 'BD', ccBarbados = 'BB',
  ccBelarus = 'BY', ccBelgium = 'BE', ccBelize = 'BZ', ccBenin = 'BJ',
  ccBermuda = 'BM', ccBhutan = 'BT', ccBolivia = 'BO', ccBosniaAndHerzegovina = 'BA',
  ccBotswana = 'BW', ccBouvetIsland = 'BV', ccBrazil = 'BR', ccBritishIndianOceanTerritory = 'IO',
  ccBrunei = 'BN', ccBulgaria = 'BG', ccBurkinaFaso = 'BF', ccBurundi = 'BI',
  ccCambodia = 'KH', ccCameroon = 'CM', ccCanada = 'CA', ccCapeVerde = 'CV',
  ccCaymanIslands = 'KY', ccCentralAfricanRepublic = 'CF', ccChad = 'TD', ccChile = 'CL',
  ccChina = 'CN', ccChristmasIsland = 'CX', ccCocosIslands = 'CC', ccColombia = 'CO',
  ccComoros = 'KM', ccCongo = 'CG', ccDemocraticRepOfCongo = 'CD', ccCookIslands = 'CK',
  ccCostaRica = 'CR', ccCoteDIvoire = 'CI', ccCroatia = 'HR', ccCuba = 'CU',
  ccCyprus = 'CY', ccCzechRepublic = 'CZ', ccDenmark = 'DK', ccDjibouti = 'DJ',
  ccDominica = 'DM', ccDominicanRepublic = 'DO', ccEcuador = 'EC', ccEgypt = 'EG',
  ccElSalvador = 'SV', ccEquatorialGuinea = 'GQ', ccEritrea = 'ER', ccEstonia = 'EE',
  ccEthiopia = 'ET', ccFalklandIslands = 'FK', ccFaroIslands = 'FO', ccFiji = 'FJ',
  ccFinland = 'FI', ccFrance = 'FR', ccFrenchGuiana = 'GF', ccFrenchPolynesia = 'PF',
  ccFrenchSouthernTerritories = 'TF', ccGabon = 'GA', ccGambia = 'GM', ccGeorgia = 'GE',
  ccGermany = 'DE', ccGhana = 'GH', ccGibraltar = 'GI', ccGreece = 'GR',
  ccGreenland = 'GL', ccGrenada = 'GD', ccGuadeloupe = 'GP', ccGuam = 'GU',
  ccGuatemala = 'GT', ccGuinea = 'GN', ccGuineaBissau = 'GW', ccGuyana = 'GY',
  ccHaiti = 'HT', ccHeardIslandAndMcdonaldIslands = 'HM', ccVaticanCity = 'VA', ccHonduras = 'HN',
  ccHongKong = 'HK', ccHungary = 'HU', ccIceland = 'IS', ccIndia = 'IN',
  ccIndonesia = 'ID', ccIran = 'IR', ccIraq = 'IQ', ccIreland = 'IE',
  ccIsrael = 'IL', ccItaly = 'IT', ccJamaica = 'JM', ccJapan = 'JP',
  ccJordan = 'JO', ccKazakhstan = 'KZ', ccKenya = 'KE', ccKiribati = 'KI',
  ccNorthKorea = 'KP', ccSouthKorea = 'KR', ccKuwait = 'KW', ccKyrgyzstan = 'KG',
  ccPeoplesRepublicOfLao = 'LA', ccLatvia = 'LV', ccLebanon = 'LB', ccLesotho = 'LS',
  ccLiberia = 'LR', ccLibyanArabJamahiriya = 'LY', ccLiechtenstein = 'LI', ccLithuania = 'LT',
  ccLuxembourg = 'LU', ccMacao = 'MO', ccMacedonia = 'MK', ccMadagascar = 'MG',
  ccMalawi = 'MW', ccMalaysia = 'MY', ccMaldives = 'MV', ccMali = 'ML',
  ccMalta = 'MT', ccMarshallIslands = 'MH', ccMartinique = 'MQ', ccMauritania = 'MR',
  ccMauritius = 'MU', ccMayotte = 'YT', ccMexico = 'MX', ccMicronesia = 'FM',
  ccMoldova = 'MD', ccMonaco = 'MC', ccMongolia = 'MN', ccMontserrat = 'MS',
  ccMorocco = 'MA', ccMozambique = 'MZ', ccMyanmar = 'MM', ccNamibia = 'NA',
  ccNauru = 'NR', ccNepal = 'NP', ccNetherlands = 'NL', ccNetherlandsAntilles = 'AN',
  ccNewCaledonia = 'NC', ccNewZealand = 'NZ', ccNicaragua = 'NI', ccNiger = 'NE',
  ccNigeria = 'NG', ccNiue = 'NU', ccNorfolkIsland = 'NF', ccNorthernMarianaIslands = 'MP',
  ccNorway = 'NO', ccOman = 'OM', ccPakistan = 'PK', ccPalau = 'PW',
  ccPalestinianTerritory = 'PS', ccPanama = 'PA', ccPapuaNewGuinea = 'PG', ccParaguay = 'PY',
  ccPeru = 'PE', ccPhilippines = 'PH', ccPitcairn = 'PN', ccPoland = 'PL',
  ccPortugal = 'PT', ccPuertoRico = 'PR', ccQatar = 'QA', ccReunion = 'RE',
  ccRomania = 'RO', ccRussianFederation = 'RU', ccRwanda = 'RW', ccSaintHelena = 'SH',
  ccSaintKitts = 'KN', ccNevis = 'KN', ccSaintLucia = 'LC', ccSaintPierre = 'PM',
  ccMiquelon = 'PM', ccSaintVincent = 'VC', ccTheGrenadines = 'VC', ccSamoa = 'WS',
  ccSanMarino = 'SM', ccSaoTome = 'ST', ccPrincipe = 'ST', ccSaudiArabia = 'SA',
  ccSenegal = 'SN', ccSerbia = 'CS', ccMontenegro = 'CS', ccSeychelles = 'SC',
  ccSierraLeone = 'SL', ccSingapore = 'SG', ccSlovakia = 'SK', ccSlovenia = 'SI',
  ccSolomonIslands = 'SB', ccSomalia = 'SO', ccSouthAfrica = 'ZA', ccSouthGeorgia = 'GS',
  ccSouthSandwichIslands = 'GS', ccSpain = 'ES', ccSriLanka = 'LK', ccSudan = 'SD',
  ccSuriname = 'SR', ccSvalbard = 'SJ', ccJanMayen = 'SJ', ccSwaziland = 'SZ',
  ccSweden = 'SE', ccSwitzerland = 'CH', ccSyrianArabRepublic = 'SY', ccTaiwan = 'TW',
  ccTajikistan = 'TJ', ccTanzania = 'TZ', ccThailand = 'TH', ccTimorLeste = 'TL',
  ccTogo = 'TG', ccTokelau = 'TK', ccTonga = 'TO', ccTrinidad = 'TT',
  ccTobago = 'TT', ccTunisia = 'TN', ccTurkey = 'TR', ccTurkmenistan = 'TM',
  ccTurksAndCaicosIslands = 'TC', ccTuvalu = 'TV', ccUganda = 'UG', ccUkraine = 'UA',
  ccUnitedArabEmirates = 'AE', ccUnitedKingdom = 'GB', ccUnitedStates = 'US', ccUnitedStatesMinorOutlyingIslands = 'UM',
  ccUruguay = 'UY', ccUzbekistan = 'UZ', ccVanuatu = 'VU', ccVenezuela = 'VE',
  ccVietNam = 'VN', ccBritishVirginIslands = 'VG', ccUSVirginIslands = 'VI', ccWallisAndFutuna = 'WF',
  ccWesternSahara = 'EH', ccYemen = 'YE', ccZaire = ccDemocraticRepOfCongo, ccZambia = 'ZM',
  ccZimbabwe = 'ZW'
}
 This enumerates all the possible country codes. More...
enum  LanguageCodes {
  lcUndefined = 0, lcAfar = 'aa', lcAbkhazian = 'ab', lcAfrikaans = 'af',
  lcAkan = 'ak', lcAlbanian = 'sq', lcAmharic = 'am', lcArabic = 'ar',
  lcAragonese = 'an', lcArmenian = 'hy', lcAssamese = 'as', lcAvaric = 'av',
  lcAvestan = 'ae', lcAymara = 'ay', lcAzerbaijani = 'az', lcBashkir = 'ba',
  lcBambara = 'bm', lcBasque = 'eu', lcBelarusian = 'be', lcBengali = 'bn',
  lcBihari = 'bh', lcBislama = 'bi', lcTibetan = 'bo', lcBosnian = 'bs',
  lcBreton = 'br', lcBulgarian = 'bg', lcBurmese = 'my', lcCatalan = 'ca',
  lcValencian = 'ca', lcCzech = 'cs', lcChamorro = 'ch', lcChechen = 'ce',
  lcChinese = 'zh', lcChurchSlavic = 'cu', lcOldSlavonic = 'cu', lcChurchSlavonic = 'cu',
  lcOldBulgarian = 'cu', lcOldChurchSlavonic = 'cu', lcChuvash = 'cv', lcCornish = 'kw',
  lcCorsican = 'co', lcCree = 'cr', lcWelsh = 'cy', lcDanish = 'da',
  lcGerman = 'de', lcDivehi = 'dv', lcFlemish = 'nl', lcDutch = 'nl',
  lcDzongkha = 'dz', lcGreek = 'el', lcEnglish = 'en', lcEsperanto = 'eo',
  lcEstonian = 'et', lcEwe = 'ee', lcFaroese = 'fo', lcPersian = 'fa',
  lcFijian = 'fj', lcFinnish = 'fi', lcFrench = 'fr', lcFrisian = 'fy',
  lcFulah = 'ff', lcGeorgian = 'ka', lcGaelic = 'gd', lcScottishGaelic = 'gd',
  lcIrish = 'ga', lcGallegan = 'gl', lcManx = 'gv', lcGuarani = 'gn',
  lcGujarati = 'gu', lcHaitian = 'ht', lcHaitianCreole = 'ht', lcHausa = 'ha',
  lcHebrew = 'he', lcHerero = 'hz', lcHindi = 'hi', lcHiriMotu = 'ho',
  lcCroatian = 'hr', lcHungarian = 'hu', lcIgbo = 'ig', lcIcelandic = 'is',
  lcIdo = 'io', lcSichuanYi = 'ii', lcInuktitut = 'iu', lcInterlingue = 'ie',
  lcInterlingua = 'ia', lcIndonesian = 'id', lcInupiaq = 'ik', lcItalian = 'it',
  lcJavanese = 'jv', lcJapanese = 'ja', lcKalaallisut = 'kl', lcGreenlandic = 'kl',
  lcKannada = 'kn', lcKashmiri = 'ks', lcKanuri = 'kr', lcKazakh = 'kk',
  lcKhmer = 'km', lcKikuyu = 'ki', lcGikuyu = 'ki', lcKinyarwanda = 'rw',
  lcKirghiz = 'ky', lcKomi = 'kv', lcKongo = 'kg', lcKorean = 'ko',
  lcKuanyama = 'kj', lcKwanyama = 'kj', lcKurdish = 'ku', lcLao = 'lo',
  lcLatin = 'la', lcLatvian = 'lv', lcLimburgan = 'li', lcLimburger = 'li',
  lcLimburgish = 'li', lcLingala = 'ln', lcLithuanian = 'lt', lcLuxembourgish = 'lb',
  lcLetzeburgesch = 'lb', lcLubaKatanga = 'lu', lcGanda = 'lg', lcMacedonian = 'mk',
  lcMarshallese = 'mh', lcMalayalam = 'ml', lcMaori = 'mi', lcMarathi = 'mr',
  lcMalay = 'ms', lcMalagasy = 'mg', lcMaltese = 'mt', lcMoldavian = 'mo',
  lcMongolian = 'mn', lcNauru = 'na', lcNavajo = 'nv', lcNavaho = 'nv',
  lcSouthNdebele = 'nr', lcNorthNdebele = 'nd', lcNdonga = 'ng', lcNepali = 'ne',
  lcNorwegianNynorsk = 'nn', lcNorwegianBokmal = 'nb', lcNorwegian = 'no', lcChichewa = 'ny',
  lcChewa = 'ny', lcNyanja = 'ny', lcOccitan = 'oc', lcProvencal = 'oc',
  lcOjibwa = 'oj', lcOriya = 'or', lcOromo = 'om', lcOssetian = 'os',
  lcOssetic = 'os', lcPunjabi = 'pa', lcPali = 'pi', lcPolish = 'pl',
  lcPortuguese = 'pt', lcPushto = 'ps', lcQuechua = 'qu', lcRaetoRomance = 'rm',
  lcRomanian = 'ro', lcRundi = 'rn', lcRussian = 'ru', lcSango = 'sg',
  lcSanskrit = 'sa', lcSerbian = 'sr', lcSinhalese = 'si', lcSlovak = 'sk',
  lcSlovenian = 'sl', lcNorthernSami = 'se', lcSamoan = 'sm', lcShona = 'sn',
  lcSindhi = 'sd', lcSomali = 'so', lcSotho = 'st', lcSpanish = 'es',
  lcSardinian = 'sc', lcSwati = 'ss', lcSundanese = 'su', lcSwahili = 'sw',
  lcSwedish = 'sv', lcTahitian = 'ty', lcTamil = 'ta', lcTatar = 'tt',
  lcTelugu = 'te', lcTajik = 'tg', lcTagalog = 'tl', lcThai = 'th',
  lcTigrinya = 'ti', lcTonga = 'to', lcTswana = 'tn', lcTsonga = 'ts',
  lcTurkmen = 'tk', lcTurkish = 'tr', lcTwi = 'tw', lcUighur = 'ug',
  lcUkrainian = 'uk', lcUrdu = 'ur', lcUzbek = 'uz', lcVenda = 've',
  lcVietnamese = 'vi', lcVolapuk = 'vo', lcWalloon = 'wa', lcWolof = 'wo',
  lcXhosa = 'xh', lcYiddish = 'yi', lcYoruba = 'yo', lcZhuang = 'za',
  lcChuang = 'za', lcZulu = 'zu'
}
 This enumerates all the possible language codes. More...

Public Member Functions

 Locale (const UnicodeString &languageCode, const UnicodeString &countryCode)
 Construct a new locale instance from a language code string, and a country code string.
 Locale (const LanguageCodes &languageCode, const CountryCodes &countryCode)
virtual ~Locale ()
LanguageCodes getLanguageCode ()
CountryCodes getCountryCode ()
UnicodeString getLanguageCodeString ()
 Returns the locale's ISO-639-1 language code.
UnicodeString getLanguageName ()
 Returns the english full language name as specified by ISO-639-2.
UnicodeString getCountryCodeString ()
 Get the ISO-3166 country code.
UnicodeString getName ()
 returns a string that is a combination of the language code, an "_", and the country code.
int collate (const UnicodeString &s1, const UnicodeString &s2)
 Collates, or compares, taking case into consideration, two strings.
int collateCaseInsensitive (const UnicodeString &s1, const UnicodeString &s2)
 Collates, or compares, two strings, ignoring their case.
UnicodeString toString (const int &val)
 converts the integer val into a UnicodeString.
UnicodeString toString (const unsigned int &val)
UnicodeString toString (const long &val)
UnicodeString toString (const unsigned long &val)
UnicodeString toString (const double &val)
UnicodeString toString (const float &val)
UnicodeString toStringFromCurrency (const double &val)
 Converts a double currency value into a string.
UnicodeString toStringFromDate (const DateTime &val, const UnicodeString &format="")
 converts a date/time instance into a string representing the date portion of the DateTime instance.
UnicodeString toStringFromTime (const DateTime &val, const UnicodeString &format="")
 converts a date/time instance into a string representing the time portion of the DateTime instance.
int toInt (const UnicodeString &str)
 Converts a string to a integer.
unsigned int toUInt (const UnicodeString &str)
double toDouble (const UnicodeString &str)
float toFloat (const UnicodeString &str)
double toDoubleAsCurrency (const UnicodeString &str)
DateTime toDateTime (const UnicodeString &str)
UnicodeString toLowerCase (const UnicodeString &s)
 Transforms all alpha numeric characters in a string to lower case.
UnicodeString toUpperCase (const UnicodeString &s)
 Transforms all alpha numeric characters in a string to upper case.
UnicodeString getNumberThousandsSeparator ()
UnicodeString getNumberDecimalPoint ()
UnicodeString getNumberGrouping ()
UnicodeString getCurrencyDecimalPoint ()
UnicodeString getCurrencyThousandsSeparator ()
UnicodeString getCurrencySymbol ()
int getCurrencyFractionalDigits ()
UnicodeString getCurrencyPositiveSign ()
UnicodeString getCurrencyNegativeSign ()
bool isCharA (const int32 &charTypeMask, const VCFChar &c)
UnicodeString translate (const UnicodeString &id)
LocalePeergetPeer ()
UnicodeString::LanguageEncoding getEncoding () const
void setEncoding (UnicodeString::LanguageEncoding val)

Static Public Member Functions

static UnicodeString languageCodeToString (LanguageCodes code)
static UnicodeString countryCodeToString (CountryCodes code)
static LanguageCodes stringToLanguageCode (const UnicodeString &code)
static CountryCodes stringToCountryCode (const UnicodeString &code)

Protected Attributes

LocalePeerpeer_
UnicodeString::LanguageEncoding encoding_

Detailed Description

A locale instance represents the cultural data used to convert data to string in manner appropriate to the language and country.

Each locale is identified by a language and a country code, where the language code is one of the possible values as listed by ISO-639-1, and the country code is one of the possible values as listed in ISO-3166. The complete locale is referred to as a combination of both these values, for example, the french locale is referred to as "fr_FR", and the United States locale is referred to as "en_US".

A locale offers a variety of methods to translate data into a string, based on the rules of the locale. For example, monetary units are represented by the dollar symbol ("$") in the "en_US" locale, but the United Kindom ("en_GB") are represented by the pound ("£"). Other functions include the ability to sort 2 strings based on the locale's sorting rules (also referred to as "collation"), transforming numerical data (ints, longs, doubles, etc) to a string. For example:

Locale loc("en_US"); //United States
String numString = loc.toString( 123456 ); //numString = "123,456"

Locale loc("it_IT"); //Italy
String numString = loc.toString( 123456 ); //numString = "123.456"
You can also convert currency data (as a double) to a string.

There are date and time functions for transforming a DateTime instance into a string that is representative of the time in hours, minutes, and seconds, and into a string that represents the date.

There are case transformation functions, to convert a string into all upper case or into all lowercase.


Member Enumeration Documentation

enum VCF::Locale::CountryCodes
 

This enumerates all the possible country codes.

The value of each code is exactly that as specified in ISO-3166.

Enumerator:
ccUndefined 
ccAfghanistan 
ccAlbania 
ccAlgeria 
ccAmericanSamoa 
ccAndorra 
ccAngola 
ccAnguilla 
ccAntarctica 
ccAntiguaAndBarbuda 
ccArgentina 
ccArmenia 
ccAruba 
ccAustralia 
ccAustria 
ccAzerbaijan 
ccBahamas 
ccBahrain 
ccBangladesh 
ccBarbados 
ccBelarus 
ccBelgium 
ccBelize 
ccBenin 
ccBermuda 
ccBhutan 
ccBolivia 
ccBosniaAndHerzegovina 
ccBotswana 
ccBouvetIsland 
ccBrazil 
ccBritishIndianOceanTerritory 
ccBrunei 
ccBulgaria 
ccBurkinaFaso 
ccBurundi 
ccCambodia 
ccCameroon 
ccCanada 
ccCapeVerde 
ccCaymanIslands 
ccCentralAfricanRepublic 
ccChad 
ccChile 
ccChina 
ccChristmasIsland 
ccCocosIslands 
ccColombia 
ccComoros 
ccCongo 
ccDemocraticRepOfCongo 
ccCookIslands 
ccCostaRica 
ccCoteDIvoire 
ccCroatia 
ccCuba 
ccCyprus 
ccCzechRepublic 
ccDenmark 
ccDjibouti 
ccDominica 
ccDominicanRepublic 
ccEcuador 
ccEgypt 
ccElSalvador 
ccEquatorialGuinea 
ccEritrea 
ccEstonia 
ccEthiopia 
ccFalklandIslands 
ccFaroIslands 
ccFiji 
ccFinland 
ccFrance 
ccFrenchGuiana 
ccFrenchPolynesia 
ccFrenchSouthernTerritories 
ccGabon 
ccGambia 
ccGeorgia 
ccGermany 
ccGhana 
ccGibraltar 
ccGreece 
ccGreenland 
ccGrenada 
ccGuadeloupe 
ccGuam 
ccGuatemala 
ccGuinea 
ccGuineaBissau 
ccGuyana 
ccHaiti 
ccHeardIslandAndMcdonaldIslands 
ccVaticanCity 
ccHonduras 
ccHongKong 
ccHungary 
ccIceland 
ccIndia 
ccIndonesia 
ccIran 
ccIraq 
ccIreland 
ccIsrael 
ccItaly 
ccJamaica 
ccJapan 
ccJordan 
ccKazakhstan 
ccKenya 
ccKiribati 
ccNorthKorea 
ccSouthKorea 
ccKuwait 
ccKyrgyzstan 
ccPeoplesRepublicOfLao 
ccLatvia 
ccLebanon 
ccLesotho 
ccLiberia 
ccLibyanArabJamahiriya 
ccLiechtenstein 
ccLithuania 
ccLuxembourg 
ccMacao 
ccMacedonia 
ccMadagascar 
ccMalawi 
ccMalaysia 
ccMaldives 
ccMali 
ccMalta 
ccMarshallIslands 
ccMartinique 
ccMauritania 
ccMauritius 
ccMayotte 
ccMexico 
ccMicronesia 
ccMoldova 
ccMonaco