toUTFz and WinAPI GetTextExtentPoint32W

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Sep 20 14:27:36 PDT 2011


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.


More information about the Digitalmars-d-learn mailing list