On Sunday, 6 August 2017 at 05:31:51 UTC, Marco Leise wrote:
Am Sat, 05 Aug 2017 20:17:23 +0000
schrieb bitwise <bitwise....@gmail.com>:

[...]

In due diligence, you are casting an ANSI string into a UTF-8
string which will result in broken Unicode for non-ASCII window
titles. In any case it is better to use the wide-character
versions of Windows-API functions nowadays.
[...]

Good point. (pun not originally intended ;)

All serious projects I have done for Windows thus far have actually been in C# (default UTF-16), so I guess I've been spoiled.

Second I'd like to mention that you should have set ret.length = GetWindowText(_hwnd, (char*)ret.ptr, ret.length); Currently your length is anything from 1 to N bytes longer than the actual string[2], which is not obvious because any debug printing or display of the string stops at the embedded \0 terminator.
[...]

Totally right! I looked right at this info in the docs..not sure how I still got it wrong ;)

 Thanks

Reply via email to