ReactOS 0.4.15-dev-5664-g3bf4ef6
locale.cpp
Go to the documentation of this file.
1#include <exception>
2#include <iostream>
3#include <locale>
4#include <ctime>
5
6using namespace std;
7
8void main()
9{
10 try
11 {
12 locale c_loc;
13 //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);
14 locale sys(".ocp");
15 locale::global(sys);
16 cin.imbue(sys);
17 cout.imbue(sys);
18
19 cout<<"Locale name is: "<<sys.name().c_str()<<'\n';
20
21 cout<<"Enter real number:";
22 double value;
23 cin>>value;
24 cout<<value<<'\n';
25
26 // Time test.
27 long lcur_time;
28 time(&lcur_time);
29 struct tm* cur_time=localtime(&lcur_time);
30
31 const numpunct<char>& num_punct=use_facet<numpunct<char> >(cout.getloc());
32 cout << num_punct.decimal_point() << '\n';
34 use_facet<time_put<char, ostreambuf_iterator<char, char_traits<char> > > >(cout.getloc());
35 time_fac.put(cout, cout, NULL, cur_time, 'x'); cout<<'\n';
36 time_fac.put(cout, cout, NULL, cur_time, 'x', '#'); cout<<'\n';
37 time_fac.put(cout, cout, NULL, cur_time, 'X'); cout<<'\n';
38 time_fac.put(cout, cout, NULL, cur_time, 'c'); cout<<'\n';
39 time_fac.put(cout, cout, NULL, cur_time, 'c', '#'); cout<<'\n';
40 time_fac.put(cout, cout, NULL, cur_time, 'I'); cout<<'\n';
41
42 const ctype<char>& char_type=use_facet<ctype<char> >(cout.getloc());
43 if(char_type.is(ctype_base::upper, '')) puts("Upper");
44 if(char_type.is(ctype_base::lower, '')) puts("Lower");
45 puts("Next");
46 if(isupper('', cout.getloc())) puts("Upper");
47 if(islower('', cout.getloc())) puts("Lower");
48 /*for(int ch=128; ch<256; ch++)
49 printf("Character %c (%d) - upper %c, lower %c\n",(char)ch, ch,toupper((char)ch, cout.getloc()), tolower((char)ch, cout.getloc()));*/
50 }
51 catch(exception &e)
52 {
53 cout<<"Exception fired:\n"<<e.what()<<'\n';
54 }
55 catch(...)
56 {
57 cout<<"Unknown exception throwed!\n";
58 }
59 cout.flush();
60}
#define islower(c)
Definition: acclib.h:72
#define isupper(c)
Definition: acclib.h:71
@ lower
Definition: _ctype.h:46
@ upper
Definition: _ctype.h:45
Definition: _ctype.h:58
Definition: _locale.h:75
static locale _STLP_CALL global(const locale &)
Definition: locale.cpp:409
string name() const
Definition: locale.cpp:388
_OutIt put(iter_type __s, ios_base &__f, _Ch __fill, const tm *__tmb, const _Ch *__pat, const _Ch *__pat_end) const
int puts(const char *string)
Definition: crtsupp.c:23
time_t cur_time
#define NULL
Definition: types.h:112
#define cout
Definition: iostream.cpp:38
#define cin
Definition: iostream.cpp:37
#define e
Definition: ke_i.h:82
__u16 time
Definition: mkdosfs.c:8
Definition: features.h:417
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
Definition: time.h:68
void main()
Definition: locale.cpp:8
Definition: pdh_main.c:94