]> git.saurik.com Git - wxWidgets.git/commitdiff
added convenience functions wxString::To/From8BitData() for storing g binary data...
authorVáclav Slavík <vslavik@fastmail.fm>
Wed, 2 May 2007 18:08:56 +0000 (18:08 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Wed, 2 May 2007 18:08:56 +0000 (18:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/wxstring.tex
include/wx/string.h

index 544bd558212e1904fd283bfe2f83e5f87d8476a6..3a35293c249189d2edd8b697b431f99050101ff9 100644 (file)
@@ -747,6 +747,24 @@ Returns the number of occurrences of {\it ch} in the string.
 
 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
 
 
 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
 
+\membersection{wxString::From8BitData}\label{wxstringfrom8bitdata}
+
+\func{static wxString }{From8BitData}{\param{const char*}{ buf}, \param{size\_t}{len}}
+
+\func{static wxString }{From8BitData}{\param{const char*}{ buf}}
+
+Converts given buffer of binary data from 8-bit string to wxString. In Unicode
+build, the string is interpreted as being in ISO-8859-1 encoding. The version
+without \arg{len} parameter takes NUL-terminated data.
+
+This is a convenience method useful when storing binary data in wxString.
+
+\newsince{2.8.4}
+
+\wxheading{See also}
+
+\helpref{To8BitData}{wxstringto8bitdata}
+
 
 \membersection{wxString::FromAscii}\label{wxstringfromascii}
 
 
 \membersection{wxString::FromAscii}\label{wxstringfromascii}
 
@@ -1124,6 +1142,26 @@ This is a wxWidgets 1.xx compatibility function, use \helpref{Mid}{wxstringmid}
 instead (but note that parameters have different meaning).
 
 
 instead (but note that parameters have different meaning).
 
 
+\membersection{wxString::To8BitData}\label{wxstringto8bitdata}
+
+\constfunc{const char*}{To8BitData}{\void}
+
+Converts the string to an 8-bit string (ANSI builds only).
+
+\constfunc{const wxCharBuffer}{To8BitData}{\void}
+
+Converts the string to an 8-bit string in ISO-8859-1 encoding in the form of
+a wxCharBuffer (Unicode builds only).
+
+This is a convenience method useful when storing binary data in wxString.
+
+\newsince{2.8.4}
+
+\wxheading{See also}
+
+\helpref{From8BitData}{wxstringfrom8bitdata}
+
+
 \membersection{wxString::ToAscii}\label{wxstringtoascii}
 
 \constfunc{const char*}{ToAscii}{\void}
 \membersection{wxString::ToAscii}\label{wxstringtoascii}
 
 \constfunc{const char*}{ToAscii}{\void}
index 43bde5e5c1636290927bcc2a4c8d31af5a98f00b..9c4746df8309db09a4b4ea59136a8abf6cab47ee 100644 (file)
@@ -1126,6 +1126,23 @@ public:
     const char *ToAscii() const { return c_str(); }
 #endif // Unicode/!Unicode
 
     const char *ToAscii() const { return c_str(); }
 #endif // Unicode/!Unicode
 
+    // functions for storing binary data in wxString:
+#if wxUSE_UNICODE
+    static wxString From8BitData(const char *data, size_t len)
+      { return wxString(data, wxConvISO8859_1, len); }
+    // version for NUL-terminated data:
+    static wxString From8BitData(const char *data)
+      { return wxString(data, wxConvISO8859_1); }
+    const wxCharBuffer To8BitData() const { return mb_str(wxConvISO8859_1); }
+#else // ANSI
+    static wxString From8BitData(const char *data, size_t len)
+      { return wxString(data, len); }
+    // version for NUL-terminated data:
+    static wxString From8BitData(const char *data)
+      { return wxString(data); }
+    const char *To8BitData() const { return c_str(); }
+#endif // Unicode/ANSI
+
     // conversions with (possible) format conversions: have to return a
     // buffer with temporary data
     //
     // conversions with (possible) format conversions: have to return a
     // buffer with temporary data
     //