Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlocale.cpp
Go to the documentation of this file.
00001 #include <exception> 00002 #include <iostream> 00003 #include <locale> 00004 #include <ctime> 00005 00006 using namespace std; 00007 00008 void main() 00009 { 00010 try 00011 { 00012 locale c_loc; 00013 //locale sys(c_loc, "LC_TIME=UKR_UKR.OCP;LC_NUMERIC=RUS_RUS.OCP;LC_CTYPE=ukr_ukr.ocp;", locale::numeric | locale::time | locale::ctype); 00014 locale sys(".ocp"); 00015 locale::global(sys); 00016 cin.imbue(sys); 00017 cout.imbue(sys); 00018 00019 cout<<"Locale name is: "<<sys.name().c_str()<<'\n'; 00020 00021 cout<<"Enter real number:"; 00022 double value; 00023 cin>>value; 00024 cout<<value<<'\n'; 00025 00026 // Time test. 00027 long lcur_time; 00028 time(&lcur_time); 00029 struct tm* cur_time=localtime(&lcur_time); 00030 00031 const numpunct<char>& num_punct=use_facet<numpunct<char> >(cout.getloc()); 00032 cout << num_punct.decimal_point() << '\n'; 00033 const time_put<char, ostreambuf_iterator<char, char_traits<char> > >& time_fac= 00034 use_facet<time_put<char, ostreambuf_iterator<char, char_traits<char> > > >(cout.getloc()); 00035 time_fac.put(cout, cout, NULL, cur_time, 'x'); cout<<'\n'; 00036 time_fac.put(cout, cout, NULL, cur_time, 'x', '#'); cout<<'\n'; 00037 time_fac.put(cout, cout, NULL, cur_time, 'X'); cout<<'\n'; 00038 time_fac.put(cout, cout, NULL, cur_time, 'c'); cout<<'\n'; 00039 time_fac.put(cout, cout, NULL, cur_time, 'c', '#'); cout<<'\n'; 00040 time_fac.put(cout, cout, NULL, cur_time, 'I'); cout<<'\n'; 00041 00042 const ctype<char>& char_type=use_facet<ctype<char> >(cout.getloc()); 00043 if(char_type.is(ctype_base::upper, '')) puts("Upper"); 00044 if(char_type.is(ctype_base::lower, '')) puts("Lower"); 00045 puts("Next"); 00046 if(isupper('', cout.getloc())) puts("Upper"); 00047 if(islower('', cout.getloc())) puts("Lower"); 00048 /*for(int ch=128; ch<256; ch++) 00049 printf("Character %c (%d) - upper %c, lower %c\n",(char)ch, ch,toupper((char)ch, cout.getloc()), tolower((char)ch, cout.getloc()));*/ 00050 } 00051 catch(exception &e) 00052 { 00053 cout<<"Exception fired:\n"<<e.what()<<'\n'; 00054 } 00055 catch(...) 00056 { 00057 cout<<"Unknown exception throwed!\n"; 00058 } 00059 cout.flush(); 00060 } Generated on Sat May 26 2012 04:34:02 for ReactOS by
1.7.6.1
|