-#if wxUSE_STL_BASED_WXSTRING
- // return an empty wxString (not very useful with wxUSE_STL == 1)
- inline const wxString wxGetEmptyString() { return wxString(); }
-#else // !wxUSE_STL_BASED_WXSTRING
- // return an empty wxString (more efficient than wxString() here)
- inline const wxString& wxGetEmptyString()
+#define wxGetEmptyString() wxString()
+
+// ----------------------------------------------------------------------------
+// helper functions which couldn't be defined inline
+// ----------------------------------------------------------------------------
+
+namespace wxPrivate
+{
+
+#if wxUSE_UNICODE_WCHAR
+
+template <>
+struct wxStringAsBufHelper<char>
+{
+ static wxCharBuffer Get(const wxString& s, size_t *len)
+ {
+ wxCharBuffer buf(s.mb_str());
+ if ( len )
+ *len = buf ? strlen(buf) : 0;
+ return buf;
+ }
+};
+
+template <>
+struct wxStringAsBufHelper<wchar_t>
+{
+ static wxWCharBuffer Get(const wxString& s, size_t *len)
+ {
+ if ( len )
+ *len = s.length();
+ return wxWCharBuffer::CreateNonOwned(s.wx_str());
+ }
+};
+
+#elif wxUSE_UNICODE_UTF8
+
+template <>
+struct wxStringAsBufHelper<char>
+{
+ static wxCharBuffer Get(const wxString& s, size_t *len)
+ {
+ if ( len )
+ *len = s.utf8_length();
+ return wxCharBuffer::CreateNonOwned(s.wx_str());
+ }
+};
+
+template <>
+struct wxStringAsBufHelper<wchar_t>
+{
+ static wxWCharBuffer Get(const wxString& s, size_t *len)