]>
Commit | Line | Data |
---|---|---|
dd0ef332 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/common/unichar.cpp | |
3 | // Purpose: wxUniChar and wxUniCharRef classes | |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2007-03-19 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2007 REA Elektronik GmbH | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // =========================================================================== | |
12 | // headers | |
13 | // =========================================================================== | |
14 | ||
15 | // For compilers that support precompilation, includes "wx.h". | |
16 | #include "wx/wxprec.h" | |
17 | ||
18 | #ifdef __BORLANDC__ | |
19 | #pragma hdrstop | |
20 | #endif | |
21 | ||
0cb6a6e4 VZ |
22 | #ifndef WX_PRECOMP |
23 | #include "wx/strconv.h" // wxConvLibc | |
24 | #endif | |
25 | ||
dd0ef332 VS |
26 | #include "wx/unichar.h" |
27 | ||
28 | // =========================================================================== | |
29 | // implementation | |
30 | // =========================================================================== | |
31 | ||
32 | /* static */ | |
d1b7ed67 | 33 | wxUniChar::value_type wxUniChar::From8bit(char c) |
dd0ef332 VS |
34 | { |
35 | // all supported charsets have the first 128 characters same as ASCII: | |
36 | if ( (unsigned char)c < 0x80 ) | |
37 | return c; | |
38 | ||
39 | wchar_t buf[2]; | |
40 | if ( wxConvLibc.ToWChar(buf, 2, &c, 1) != 2 ) | |
41 | return wxT('?'); // FIXME-UTF8: what to use as failure character? | |
42 | return buf[0]; | |
43 | } | |
44 | ||
45 | /* static */ | |
d1b7ed67 | 46 | char wxUniChar::To8bit(wxUniChar::value_type c) |
dd0ef332 VS |
47 | { |
48 | // all supported charsets have the first 128 characters same as ASCII: | |
49 | if ( c < 0x80 ) | |
50 | return c; | |
51 | ||
52 | wchar_t in = c; | |
53 | char buf[2]; | |
54 | if ( wxConvLibc.FromWChar(buf, 2, &in, 1) != 2 ) | |
55 | return '?'; // FIXME-UTF8: what to use as failure character? | |
56 | return buf[0]; | |
57 | } |