+// ----------------------------------------------------------------------------
+// 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)
+ {
+ wxWCharBuffer wbuf(s.wc_str());
+ if ( len )
+ *len = wxWcslen(wbuf);
+ return wbuf;
+ }
+};
+
+#endif // Unicode build kind
+
+} // namespace wxPrivate
+