[Issue 8384] Poor wchar/dchar* to string conversion support
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 13 13:36:07 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8384
--- Comment #2 from Vladimir Panteleev <thecybershadow at gmail.com> 2012-07-13 13:36:05 PDT ---
> to!string should take null-terminated string and give you a string, and it does
> that. This code passes:
Is it something that was fixed recently (within the last two weeks)? My
two-week-old dmd git build and dpaste still print offsets for wchar* and
dchar*: http://dpaste.dzfl.pl/26a2b284
> So, you expect %s on a pointer to give you the string that it points to? Why?
I think that, before all else, we should be looking for good reasons why
format("%s", foo) and to!string(foo) produce different results. Why should one
format the offset and the other do a conversion?
Second, I believe that the principle of least surprise is making this case
rather clear: if the programmer tries to print a char*, it's almost certain
that they want to print the null-terminated string at the given address, rather
than a hexadecimal representation of the address (which are rarely useful to
the end-user). Generic code is the only exception I can think of, in which case
a cast to void* is in order.
> What _doesn't_ work is this:
I think this should call the appropriate toUTFx functions from std.utf.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list