From 628f9e95963c344a294d74c6d60c3e99b6964cd1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 4 Aug 2007 18:40:45 +0000 Subject: [PATCH] added FromAscii(unsigned char *) overloads git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47874 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/wxstring.tex | 6 +++++- include/wx/string.h | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/latex/wx/wxstring.tex b/docs/latex/wx/wxstring.tex index b00acfe128..5016c78fbe 100644 --- a/docs/latex/wx/wxstring.tex +++ b/docs/latex/wx/wxstring.tex @@ -774,9 +774,13 @@ This is a convenience method useful when storing binary data in wxString. \func{static wxString }{FromAscii}{\param{const char*}{ s}} +\func{static wxString }{FromAscii}{\param{const unsigned char*}{ s}} + \func{static wxString }{FromAscii}{\param{const char*}{ s}, \param{size\_t}{ len}} -\func{static wxString }{FromAscii}{\param{const char}{ c}} +\func{static wxString }{FromAscii}{\param{const unsigned char*}{ s}, \param{size\_t}{ len}} + +\func{static wxString }{FromAscii}{\param{char}{ c}} Converts the string or character from an ASCII, 7-bit form to the native wxString representation. Most useful when using diff --git a/include/wx/string.h b/include/wx/string.h index cc791c7d7f..7345c36d17 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -1238,18 +1238,25 @@ public: // the behaviour of these functions with the strings containing anything // else than 7 bit ASCII characters is undefined, use at your own risk. #if wxUSE_UNICODE - static wxString FromAscii(const char *ascii, size_t len); // string - static wxString FromAscii(const char *ascii); // string - static wxString FromAscii(const char ascii); // char + static wxString FromAscii(const char *ascii, size_t len); + static wxString FromAscii(const char *ascii); + static wxString FromAscii(char ascii); const wxCharBuffer ToAscii() const; #else // ANSI static wxString FromAscii(const char *ascii) { return wxString( ascii ); } static wxString FromAscii(const char *ascii, size_t len) { return wxString( ascii, len ); } - static wxString FromAscii(const char ascii) { return wxString( ascii ); } + static wxString FromAscii(char ascii) { return wxString( ascii ); } const char *ToAscii() const { return c_str(); } #endif // Unicode/!Unicode + // also provide unsigned char overloads as signed/unsigned doesn't matter + // for 7 bit ASCII characters + static wxString FromAscii(const unsigned char *ascii) + { return FromAscii((const char *)ascii); } + static wxString FromAscii(const unsigned char *ascii, size_t len) + { return FromAscii((const char *)ascii, len); } + // conversion to/from UTF-8: #if wxUSE_UNICODE_UTF8 static wxString FromUTF8(const char *utf8) -- 2.45.2