On Wed Feb 12 13:59:51 2025 +0000, Rémi Bernon wrote:
Similar to `trim_string` you could have an `unescape_string`, which would go through the string and remove escaping `''` characters. Something like that maybe (untested):
static HRESULT unescape_string( HSTRING input, HSTRING *output ) { const WCHAR *src = WindowsGetStringRawBuffer( input, &len ), *end = src + len; HSTRING_BUFFER buf; UINT32 len, n; HRESULT hr; WCHAR *dst; for (len = n = 0; len + n < end - src; len++) { if (src[len + n] == '\') n++; } if (FAILED(hr = WindowsPreallocateStringBuffer( len, &dst, &buf )) return hr; while (src != end) { if (*src == '\' && ++src == end) break; *dst++ = *src++; } *dst = 0; return WindowsPromoteStringBuffer( buf, output ); }
Thanks, I had something similar in mind but I was hoping there would be a simpler way to remove it.