]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxchar.cpp
fix assert because of passing more than one border bit in style to the base class...
[wxWidgets.git] / src / common / wxchar.cpp
index cf4e0a5be555a94bb9ccf9090612ccf400f95d6f..9afb608e493a59fd47b9ef5abf74a7ea31abdb3d 100644 (file)
@@ -1220,7 +1220,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
 #endif // !wxVsnprintf_
 
 #if !defined(wxSnprintf_)
-int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
+int WXDLLEXPORT wxDoSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
 {
     va_list argptr;
     va_start(argptr, format);
@@ -1236,7 +1236,7 @@ int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
 #if defined(__DMC__)
     /* Digital Mars adds count to _stprintf (C99) so convert */
     #if wxUSE_UNICODE
-        int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... )
+        int wxDoSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... )
         {
             va_list arglist;
 
@@ -1576,7 +1576,7 @@ wxString wxConvertFormat(const wxChar *format)
 
 #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
 
-int wxScanf( const wxChar *format, ... )
+int wxDoScanf( const wxChar *format, ... )
 {
     va_list argptr;
     va_start(argptr, format);
@@ -1588,7 +1588,7 @@ int wxScanf( const wxChar *format, ... )
     return ret;
 }
 
-int wxSscanf( const wxChar *str, const wxChar *format, ... )
+int wxDoSscanf( const wxChar *str, const wxChar *format, ... )
 {
     va_list argptr;
     va_start(argptr, format);
@@ -1600,7 +1600,7 @@ int wxSscanf( const wxChar *str, const wxChar *format, ... )
     return ret;
 }
 
-int wxFscanf( FILE *stream, const wxChar *format, ... )
+int wxDoFscanf( FILE *stream, const wxChar *format, ... )
 {
     va_list argptr;
     va_start(argptr, format);
@@ -1611,7 +1611,7 @@ int wxFscanf( FILE *stream, const wxChar *format, ... )
     return ret;
 }
 
-int wxPrintf( const wxChar *format, ... )
+int wxDoPrintf( const wxChar *format, ... )
 {
     va_list argptr;
     va_start(argptr, format);
@@ -1624,7 +1624,7 @@ int wxPrintf( const wxChar *format, ... )
 }
 
 #ifndef wxSnprintf
-int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... )
+int wxDoSnprintf( wxChar *str, size_t size, const wxChar *format, ... )
 {
     va_list argptr;
     va_start(argptr, format);
@@ -1641,7 +1641,7 @@ int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... )
 }
 #endif // wxSnprintf
 
-int wxSprintf( wxChar *str, const wxChar *format, ... )
+int wxDoSprintf( wxChar *str, const wxChar *format, ... )
 {
     va_list argptr;
     va_start(argptr, format);
@@ -1656,7 +1656,7 @@ int wxSprintf( wxChar *str, const wxChar *format, ... )
     return s.length();
 }
 
-int wxFprintf( FILE *stream, const wxChar *format, ... )
+int wxDoFprintf( FILE *stream, const wxChar *format, ... )
 {
     va_list argptr;
     va_start( argptr, format );
@@ -2265,3 +2265,34 @@ int wxRemove(const wxChar *path)
 }
 
 #endif
+
+// ----------------------------------------------------------------------------
+// wxUniChar
+// ----------------------------------------------------------------------------
+
+/* static */
+wxUniChar::unicode_type wxUniChar::From8bit(char c)
+{
+    // all supported charsets have the first 128 characters same as ASCII:
+    if ( (unsigned char)c < 0x80 )
+        return c;
+
+    wchar_t buf[2];
+    if ( wxConvLibc.ToWChar(buf, 2, &c, 1) != 2 )
+        return wxT('?'); // FIXME-UTF8: what to use as failure character?
+    return buf[0];
+}
+
+/* static */
+char wxUniChar::To8bit(wxUniChar::unicode_type c)
+{
+    // all supported charsets have the first 128 characters same as ASCII:
+    if ( c < 0x80 )
+        return c;
+
+    wchar_t in = c;
+    char buf[2];
+    if ( wxConvLibc.FromWChar(buf, 2, &in, 1) != 2 )
+        return '?'; // FIXME-UTF8: what to use as failure character?
+    return buf[0];
+}