]> git.saurik.com Git - wxWidgets.git/blob - src/common/unichar.cpp
document GetAnimation() (patch 1695722)
[wxWidgets.git] / src / common / unichar.cpp
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
22 #ifndef WX_PRECOMP
23 #include "wx/strconv.h" // wxConvLibc
24 #endif
25
26 #include "wx/unichar.h"
27
28 // ===========================================================================
29 // implementation
30 // ===========================================================================
31
32 /* static */
33 wxUniChar::value_type wxUniChar::From8bit(char c)
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 */
46 char wxUniChar::To8bit(wxUniChar::value_type c)
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 }