added wxString::FromAscii(char*,size_t) for consistency with FromUTF8()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46995 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -770,6 +770,8 @@ 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 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 char}{ c}}
|
||||||
|
|
||||||
Converts the string or character from an ASCII, 7-bit form
|
Converts the string or character from an ASCII, 7-bit form
|
||||||
@@ -1371,10 +1373,10 @@ The macro wxWX2WCbuf is defined as the correct return type (without const).
|
|||||||
\constfunc{wxWritableWCharBuffer}{wchar\_str}{\void}
|
\constfunc{wxWritableWCharBuffer}{wchar\_str}{\void}
|
||||||
|
|
||||||
Returns an object with string data that is implicitly convertible to
|
Returns an object with string data that is implicitly convertible to
|
||||||
{\tt char*} pointer. Note that any change to the returned buffer is lost and so
|
{\tt char*} pointer. Note that changes to the returned buffer may or may
|
||||||
this function is only usable for passing strings to legacy libraries that
|
not be lost (depending on the build) and so this function is only usable for
|
||||||
don't have const-correct API. Use \helpref{wxStringBuffer}{wxstringbuffer} if
|
passing strings to legacy libraries that don't have const-correct API. Use
|
||||||
you want to modify the string.
|
\helpref{wxStringBuffer}{wxstringbuffer} if you want to modify the string.
|
||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
|
@@ -1215,11 +1215,14 @@ public:
|
|||||||
// the behaviour of these functions with the strings containing anything
|
// the behaviour of these functions with the strings containing anything
|
||||||
// else than 7 bit ASCII characters is undefined, use at your own risk.
|
// else than 7 bit ASCII characters is undefined, use at your own risk.
|
||||||
#if wxUSE_UNICODE
|
#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); // string
|
||||||
static wxString FromAscii(const char ascii); // char
|
static wxString FromAscii(const char ascii); // char
|
||||||
const wxCharBuffer ToAscii() const;
|
const wxCharBuffer ToAscii() const;
|
||||||
#else // ANSI
|
#else // ANSI
|
||||||
static wxString FromAscii(const char *ascii) { return wxString( ascii ); }
|
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(const char ascii) { return wxString( ascii ); }
|
||||||
const char *ToAscii() const { return c_str(); }
|
const char *ToAscii() const { return c_str(); }
|
||||||
#endif // Unicode/!Unicode
|
#endif // Unicode/!Unicode
|
||||||
|
@@ -973,35 +973,36 @@ int wxString::CmpNoCase(const wxString& s) const
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxString wxString::FromAscii(const char *ascii)
|
wxString wxString::FromAscii(const char *ascii, size_t len)
|
||||||
{
|
{
|
||||||
if (!ascii)
|
if (!ascii || len == 0)
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
|
||||||
size_t len = strlen(ascii);
|
|
||||||
wxString res;
|
wxString res;
|
||||||
|
|
||||||
if ( len )
|
wxImplStringBuffer buf(res, len);
|
||||||
|
wxStringCharType *dest = buf;
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
{
|
{
|
||||||
wxImplStringBuffer buf(res, len);
|
unsigned char c = (unsigned char)*ascii++;
|
||||||
wxStringCharType *dest = buf;
|
wxASSERT_MSG( c < 0x80,
|
||||||
|
_T("Non-ASCII value passed to FromAscii().") );
|
||||||
|
|
||||||
for ( ;; )
|
*dest++ = (wchar_t)c;
|
||||||
{
|
|
||||||
unsigned char c = (unsigned char)*ascii++;
|
|
||||||
wxASSERT_MSG( c < 0x80,
|
|
||||||
_T("Non-ASCII value passed to FromAscii().") );
|
|
||||||
|
|
||||||
*dest++ = (wchar_t)c;
|
if ( c == '\0' )
|
||||||
|
break;
|
||||||
if ( c == '\0' )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString wxString::FromAscii(const char *ascii)
|
||||||
|
{
|
||||||
|
return FromAscii(ascii, strlen(ascii));
|
||||||
|
}
|
||||||
|
|
||||||
wxString wxString::FromAscii(const char ascii)
|
wxString wxString::FromAscii(const char ascii)
|
||||||
{
|
{
|
||||||
// What do we do with '\0' ?
|
// What do we do with '\0' ?
|
||||||
|
Reference in New Issue
Block a user