digitalmars.D - About variadic in functions and dstring type
- Lorenzo Villani (7/7) Jan 22 2008 Hi, I want to modify or extend std.stdio.writefln in order to support (f...
- torhu (6/14) Jan 22 2008 You just need to define a toString() method for your class, then
- Janice Caron (6/9) Jan 22 2008 What dstring is varies from version to version of D, but it's always
- Janice Caron (2/4) Jan 22 2008 Sorry, I meant, for UTF-32 strings.
Hi, I want to modify or extend std.stdio.writefln in order to support (for example) a String object.. i.e.: I would like to be able to do something like that String s = new String("Hello World"); writefln(s); I thought that it should be possible by writing some sort of wrapper around the original writefln which scans the _arguments array and if an argument is a String object it does an in-place substitution of the argument to a standard D string type printable by writefln. Now let's come to my 2nd question: what are dchar and dstring and their differences from char[] (or wchar[]) ? Thanks in advance Lorenzo "Arbiter" Villani
Jan 22 2008
Lorenzo Villani wrote:Hi, I want to modify or extend std.stdio.writefln in order to support (for example) a String object.. i.e.: I would like to be able to do something like that String s = new String("Hello World"); writefln(s); I thought that it should be possible by writing some sort of wrapper around the original writefln which scans the _arguments array and if an argument is a String object it does an in-place substitution of the argument to a standard D string type printable by writefln.You just need to define a toString() method for your class, then writefln will automatically call that.Now let's come to my 2nd question: what are dchar and dstring and their differences from char[] (or wchar[]) ?dchar is a 32-bit type, for storing a UTF-32 code unit. dstring is an array of dchar, in other words a UTF-32 string. wchar and wstring are for UTF-16.
Jan 22 2008
On 1/22/08, torhu <no spam.invalid> wrote:dchar is a 32-bit type, for storing a UTF-32 code unit. dstring is an array of dchar, in other words a UTF-32 string. wchar and wstring are for UTF-16.What dstring is varies from version to version of D, but it's always the correct type to use for strings. In D1.x, dstring is an alias for dchar[] In early D2.x, dstring was an alias for const(dchar)[] In current D2.x, dstring is an alias for invariant(dchar)[]
Jan 22 2008
On 1/22/08, Janice Caron <caron800 googlemail.com> wrote:What dstring is varies from version to version of D, but it's always the correct type to use for strings.Sorry, I meant, for UTF-32 strings.
Jan 22 2008