ReactOS  0.4.14-dev-317-g96040ec
locale.cpp
Go to the documentation of this file.
1 #include <exception>
2 #include <iostream>
3 #include <locale>
4 #include <ctime>
5 
6 using namespace std;
7 
8 void 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 }
_OutIt put(iter_type __s, ios_base &__f, _Ch __fill, const tm *__tmb, const _Ch *__pat, const _Ch *__pat_end) const
time_t cur_time
__u16 time
Definition: mkdosfs.c:366
Definition: features.h:417
#define cout
Definition: iostream.cpp:38
Definition: _locale.h:75
#define e
Definition: ke_i.h:82
#define cin
Definition: iostream.cpp:37
smooth NULL
Definition: ftsmooth.c:416
#define isupper(c)
Definition: acclib.h:71
void main()
Definition: locale.cpp:8
char decimal_point() const
Definition: _numpunct.h:56
Definition: time.h:76
#define islower(c)
Definition: acclib.h:72
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:424
GLsizei const GLfloat * value
Definition: glext.h:6069
int puts(const char *string)
Definition: crtsupp.c:23
static locale _STLP_CALL global(const locale &)
Definition: locale.cpp:409
string name() const
Definition: locale.cpp:388
bool is(mask __m, char __c) const
Definition: _ctype.h:78