+#ifdef WC_UTF16
+ typedef wchar_t wxDecodeSurrogate_t;
+#else // !WC_UTF16
+ typedef wxUint16 wxDecodeSurrogate_t;
+#endif // WC_UTF16/!WC_UTF16
+
+// returns the next UTF-32 character from the wchar_t buffer and advances the
+// pointer to the character after this one
+//
+// if an invalid character is found, *pSrc is set to NULL, the caller must
+// check for this
+static wxUint32 wxDecodeSurrogate(const wxDecodeSurrogate_t **pSrc)
+{
+ wxUint32 out;
+ const size_t
+ n = decode_utf16(wx_reinterpret_cast(const wxUint16 *, *pSrc), out);
+ if ( n == wxCONV_FAILED )
+ *pSrc = NULL;
+ else
+ *pSrc += n;
+
+ return out;
+}