On Tue Feb 11 10:42:56 2025 +0000, Mohamad Al-Jaf wrote:
What if it ends with `""`? We should keep a quote in the string in
this case. Passing `json = L""Wine\"""` returns `json = L"Wine""` in Windows. This seems like an edge case. I've added a todo_wine test for it, unless there's a simple way to remove the escape characters?
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):
```c 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 ); } ```