Don't use length, use std.utf.count, ala:

import std.utf;
alias toUTFz!(const(wchar)*, string)  toUTF16z;
GetTextExtentPoint32W(str.toUTF16z, std.utf.count(str), s);

I like to keep that alias for my code since I was already using it beforehand.

I'm pretty sure (ok maybe 80% sure) that GetTextExtentPoint32W asks
for the count of characters and not code units. The WinAPI docs are a
bit fuzzy when it comes to these things, some functions take the
character count, others code-unit count. I've used this function in a
D port of a Neatpad project a while ago.

Reply via email to