Bug 6130 – utf.toUTF16z needs to be callable with any string type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-06-08T17:54:00Z
Last change time
2011-10-26T09:35:51Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-06-08T17:54:51Z
Currently only passing UTF8 strings works. wstrings should be supported too: wstring a = "foo"; toUTF16z(a); testwstring.d(12): Error: function std.utf.toUTF16z (in const(char[]) s) is not callable using argument types (immutable(wchar)[]) testwstring.d(12): Error: cannot implicitly convert expression (a) of type immutable(wchar)[] to const(char[])
Comment #1 by andrej.mitrovich — 2011-06-13T08:36:24Z
Also, dstrings should be supported. It makes it much easier to deal with the windows api when you have access to the count of code points of a string: dstring text = "ABCDE abcde ÀÁÂÃÄÅ àáâãäå"; TextOut(hdc, 0, 0, text.toUTF16z, text.length); That won't compile and I have to do this instead: TextOut(hdc, 0, 0, to!string(text).toUTF16z, text.length);
Comment #2 by andrej.mitrovich — 2011-10-26T08:46:36Z
I think this is safe to close since we now have toUTFz.
Comment #3 by issues.dlang — 2011-10-26T09:35:51Z
https://github.com/D-Programming-Language/phobos/pull/279 will actually do this, since it'll make to so that toUTF16z just calls toUTFz internally, in which case it's easy to make toUTF16z take any string type.