trace: Serialize wide-strings properly.
Wide strings are only used by DirectX APIs, mostly for descriptions, but
it's still useful to be able to read them.
I'm split on whether to bump the trace format version or not.
OpenGL traces are unaffected.
diff --git a/cli/pickle.hpp b/cli/pickle.hpp
index 35973ef..753cd6f 100644
--- a/cli/pickle.hpp
+++ b/cli/pickle.hpp
@@ -211,6 +211,34 @@
writeString(s.c_str(), s.size());
}
+ inline void writeWString(const wchar_t *s, size_t length) {
+ if (!s) {
+ writeNone();
+ return;
+ }
+
+ /* FIXME: emit UTF-8 */
+ os.put(BINUNICODE);
+ putInt32(length);
+ for (size_t i = 0; i < length; ++i) {
+ wchar_t wc = s[i];
+ char c = wc >= 0 && wc < 0x80 ? (char)wc : '?';
+ os.put(c);
+ }
+
+ os.put(BINPUT);
+ os.put(1);
+ }
+
+ inline void writeWString(const wchar_t *s) {
+ if (!s) {
+ writeNone();
+ return;
+ }
+
+ writeWString(s, wcslen(s));
+ }
+
inline void writeNone(void) {
os.put(NONE);
}