| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
January 22, 2008 About variadic in functions and dstring type | ||||
|---|---|---|---|---|
| ||||
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
| ||||
January 22, 2008 Re: About variadic in functions and dstring type | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Lorenzo Villani | 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. | |||
January 22, 2008 Re: About variadic in functions and dstring type | ||||
|---|---|---|---|---|
| ||||
Posted in reply to torhu | 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)[]
| |||
January 22, 2008 Re: About variadic in functions and dstring type | ||||
|---|---|---|---|---|
| ||||
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.
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply