sl@0
|
1 |
#include <exception>
|
sl@0
|
2 |
#include <iostream>
|
sl@0
|
3 |
#include <locale>
|
sl@0
|
4 |
#include <ctime>
|
sl@0
|
5 |
|
sl@0
|
6 |
using namespace std;
|
sl@0
|
7 |
|
sl@0
|
8 |
void main()
|
sl@0
|
9 |
{
|
sl@0
|
10 |
try
|
sl@0
|
11 |
{
|
sl@0
|
12 |
locale c_loc;
|
sl@0
|
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);
|
sl@0
|
14 |
locale sys(".ocp");
|
sl@0
|
15 |
locale::global(sys);
|
sl@0
|
16 |
cin.imbue(sys);
|
sl@0
|
17 |
cout.imbue(sys);
|
sl@0
|
18 |
|
sl@0
|
19 |
cout<<"Locale name is: "<<sys.name().c_str()<<'\n';
|
sl@0
|
20 |
|
sl@0
|
21 |
cout<<"Enter real number:";
|
sl@0
|
22 |
double value;
|
sl@0
|
23 |
cin>>value;
|
sl@0
|
24 |
cout<<value<<'\n';
|
sl@0
|
25 |
|
sl@0
|
26 |
// Time test.
|
sl@0
|
27 |
long lcur_time;
|
sl@0
|
28 |
time(&lcur_time);
|
sl@0
|
29 |
struct tm* cur_time=localtime(&lcur_time);
|
sl@0
|
30 |
|
sl@0
|
31 |
const numpunct<char>& num_punct=use_facet<numpunct<char> >(cout.getloc());
|
sl@0
|
32 |
cout << num_punct.decimal_point() << '\n';
|
sl@0
|
33 |
const time_put<char, ostreambuf_iterator<char, char_traits<char> > >& time_fac=
|
sl@0
|
34 |
use_facet<time_put<char, ostreambuf_iterator<char, char_traits<char> > > >(cout.getloc());
|
sl@0
|
35 |
time_fac.put(cout, cout, NULL, cur_time, 'x'); cout<<'\n';
|
sl@0
|
36 |
time_fac.put(cout, cout, NULL, cur_time, 'x', '#'); cout<<'\n';
|
sl@0
|
37 |
time_fac.put(cout, cout, NULL, cur_time, 'X'); cout<<'\n';
|
sl@0
|
38 |
time_fac.put(cout, cout, NULL, cur_time, 'c'); cout<<'\n';
|
sl@0
|
39 |
time_fac.put(cout, cout, NULL, cur_time, 'c', '#'); cout<<'\n';
|
sl@0
|
40 |
time_fac.put(cout, cout, NULL, cur_time, 'I'); cout<<'\n';
|
sl@0
|
41 |
|
sl@0
|
42 |
const ctype<char>& char_type=use_facet<ctype<char> >(cout.getloc());
|
sl@0
|
43 |
if(char_type.is(ctype_base::upper, '')) puts("Upper");
|
sl@0
|
44 |
if(char_type.is(ctype_base::lower, '')) puts("Lower");
|
sl@0
|
45 |
puts("Next");
|
sl@0
|
46 |
if(isupper('', cout.getloc())) puts("Upper");
|
sl@0
|
47 |
if(islower('', cout.getloc())) puts("Lower");
|
sl@0
|
48 |
/*for(int ch=128; ch<256; ch++)
|
sl@0
|
49 |
printf("Character %c (%d) - upper %c, lower %c\n",(char)ch, ch,toupper((char)ch, cout.getloc()), tolower((char)ch, cout.getloc()));*/
|
sl@0
|
50 |
}
|
sl@0
|
51 |
catch(exception &e)
|
sl@0
|
52 |
{
|
sl@0
|
53 |
cout<<"Exception fired:\n"<<e.what()<<'\n';
|
sl@0
|
54 |
}
|
sl@0
|
55 |
catch(...)
|
sl@0
|
56 |
{
|
sl@0
|
57 |
cout<<"Unknown exception throwed!\n";
|
sl@0
|
58 |
}
|
sl@0
|
59 |
cout.flush();
|
sl@0
|
60 |
}
|