C Standard Libraries C++



char* setlocale(int iCategory, const char* kcpLocale);


Set the locale for the category designated by the argument "iCategory" to the locale given in the argument "kcpLocale." The return value is a string describing the locale new setting, if the function was successful. The allowed options for the locale string are as follows: language (e.g. "english"), language underscore region (e.g. "english_united states"), language underscore region with code page extension (e.g. "english_united states.OCP"), or any of the special codes (e.g. ".ACP").

Category Macros Table


LC_ALLAffects all categories0
LC_COLLATEAffects collate functions like strcoll()1
LC_CTYPEAffects most ctype character functions2
LC_MONETARYAffects monetary information3
LC_NUMERICAffects decimal point character4
LC_TIMEAffects time functions5
LC_MINMin value0
LC_MAXMax value5

Locale Strings Table (Language)


Chinese (simplified)"chinese-simplified" or "chs"
Chinese (traditional)"chinese-traditional" or "cht"
Czech"csy" or "czech"
Danish"dan" or "danish"
Dutch (default)"dutch" or "nld"
Dutch (Belgium)"belgian", "dutch-belgian", or "nlb"
English (default)"english"
English (Australia)"australian", "ena", or "english-aus"
English (Canada)"canadian", "enc", or "english-can"
English (New Zealand)"english-nz" or "enz"
English (United Kingdom)"eng", "english-uk", or "uk"
English (United States)"american", "american english", "american-english", "english-american", "english-us", "english-usa", "enu", "us", or "usa"
Finnish"fin" or "finnish"
French (default)"fra" or "french"
French (Belgium)"frb" or "french-belgian"
French (Canada)"frc" or "french-canadian"
French (Switzerland)"french-swiss" or "frs"
German (default)"deu" or "german"
German (Austria)"dea" or "german-austrian"
German (Switzerland)"des", "german-swiss", or "swiss"
Greek"ell" or "greek"
Hungarian"hun" or "hungarian"
Icelandic"icelandic" or "isl"
Italian (default)"ita" or "italian"
Italian (Switzerland)"italian-swiss" or "its"
Japanese"japanese" or "jpn"
Korean"kor" or "korean"
Norwegian (default)"norwegian"
Norwegian (Bokmal)"nor" or "norwegian-bokmal"
Norwegian (Nynorsk)"non" or "norwegian-nynorsk"
Polish"plk" or "polish"
Portuguese (default)"portuguese" or "ptg"
Portuguese (Brazil)"portuguese-brazilian" or "ptb"
Russian (default)"rus" or "russian"
Slovak"sky" or "slovak"
Spanish (default)"esp" or "spanish"
Spanish (Mexico)"esm" or "spanish-mexican"
Spanish (Modern)"esn" or "spanish-modern"
Swedish"sve" or "swedish"
Turkish"trk" or "turkish"

Locale Strings Table (Regional)


Australia"aus" or "australia"
Austria"aut" or "austria"
Belgium"bel" or "belgium"
Brazil"bra" or "brazil"
Canada"can" or "canada"
China"china", "chn", "pr china", or "pr-china"
Czech Republic"cze" or "czech"
Denmark"dnk" or "denmark"
Finland"fin" or "finland"
France"fra" or "france"
Germany"deu" or "germany"
Greece"grc" or "greece"
Hong Kong SAR"hkg", "hong kong", or "hong-kong"
Hungary"hun" or "hungary"
Iceland"iceland" or "isl"
Ireland"irl" or "ireland"
Italy"ita" or "italy"
Japan"jpn" or "japan"
Korea"kor" or "korea"
Mexico"mex" or "mexico"
The Netherlands"nld", "holland", or "netherlands"
New Zealand"nzl", "new zealand", "new-zealand", or "nz"
Norway"nor" or "norway"
Poland"pol" or "poland"
Portugal"prt" or "portugal"
Russia"rus" or "russia"
Singapore"sgp" or "singapore"
Slovakia"svk" or "slovak"
Spain"esp" or "spain"
Sweden"swe" or "sweden"
Switzerland"che" or "switzerland"
Taiwan"twn" or "taiwan"
Turkey"tur" or "turkey"
United Kingdom"gbr", "britain", "england", "great britain", "uk", "united kingdom", or "united-kingdom"
United States"usa", "america", "united states", "united-states", or "us"

Locale Strings Table (Special)


Set nothing, just reportNULL
Start up value"C"
User default from OS""
Current OEM code page".OCP"
ANSI code page".ACP"


#include <iostream>
#include <clocale>

int main() {
    using namespace std;

    char* cpSettings = setlocale(LC_ALL, "usa");
    cout << cpSettings << endl;

    return 0;


setlocale() Output

© 2007–2024 XoaX.net LLC. All rights reserved.