www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - toStringz for UTF-16

reply "Katayama Hirofumi MZ" <katayama.hirofumi.mz gmail.com> writes:
Why doesn't D have toStringz function for UTF-16 encoding?
Oct 12 2012
next sibling parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Saturday, October 13, 2012 01:58:15 Katayama Hirofumi MZ wrote:
 Why doesn't D have toStringz function for UTF-16 encoding?
It does. std.utf.toUTFz will do every combination of char type and constness. And std.utf.toUTF16z will convert any string to a null-terminated const(wchar)*. - Jonathan M Davis
Oct 12 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-10-13 02:04, Jonathan M Davis wrote:

 It does. std.utf.toUTFz will do every combination of char type and constness.
 And std.utf.toUTF16z will convert any string to a null-terminated
 const(wchar)*.
Shouldn't we deprecate "toUTF16z" if "toUTFz" can handle all cases that "toUTF16z" does? -- /Jacob Carlborg
Oct 13 2012
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 10/13/12, Jacob Carlborg <doob me.com> wrote:
 On 2012-10-13 02:04, Jonathan M Davis wrote:
 Shouldn't we deprecate "toUTF16z" if "toUTFz" can handle all cases that
 "toUTF16z" does?
This was already proposed before, but it would break too much code. Anyway there's nothing wrong in having an alias that makes typing simpler, e.g. toUTF16z vs toUTF!(const(wchar)*). Phobos has many helper auto functions which make instantiating templates simpler, toUTF16z has that same kind of role.
Oct 13 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-10-13 15:45, Andrej Mitrovic wrote:

 This was already proposed before, but it would break too much code.
 Anyway there's nothing wrong in having an alias that makes typing
 simpler, e.g. toUTF16z vs toUTF!(const(wchar)*).

 Phobos has many helper auto functions which make instantiating
 templates simpler, toUTF16z has that same kind of role.
Fair enough. -- /Jacob Carlborg
Oct 14 2012
prev sibling parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Saturday, October 13, 2012 01:58:15 Katayama Hirofumi MZ wrote:
 Why doesn't D have toStringz function for UTF-16 encoding?
std.utf.toUTFz will do every combination of char type and constness. And std.utf.toUTF16z will convert any string to a null-terminated const(wchar)*. - Jonathan M Davis
Oct 12 2012
parent "Katayama Hirofumi MZ" <katayama.hirofumi.mz gmail.com> writes:
Thanks.


---- END OF THREAD ----
Oct 12 2012