X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/13ab552e4d5a6fbc443825eadba12d81f2b3f5be..88c23b64c7cc5ea6f6e2841ba40cc81bf943c27a:/src/common/wxchar.cpp diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index cf4e0a5be5..9afb608e49 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -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]; +}