Append wchar enumeration to string

Steven Schveighoffer schveiguy at yahoo.com
Mon Nov 22 08:25:25 PST 2010


On Sun, 21 Nov 2010 05:58:30 -0500, Nrgyzer <nrgyzer at gmail.com> wrote:

> Hello guys,
>
> I have an enumeration which contains symbols of different currencies
> like the following:
>
> enum CURRENCY : wchar {
>
> 	DOLLAR = '$',
> 	EURO = '�',
> 	YEN = ...
>
> }
>
> When I try to append it to a string like
>
> char[] myString = "Currency: " ~ CURRENCY.DOLLAR
>
> I get the following error: "Error: incompatible types for... 'char[]'
> and 'int'"

I'm guessing from the code/error, this is D1.  D2 does support appending  
different width characters to dchar[], I'm not sure about appending wchar  
to a char[] though.

I don't think D1 has such support.

It also doesn't have support for enums as strings, so I think you may just  
have to create a function that returns a char[], given a wchar.

-Steve


More information about the Digitalmars-d-learn mailing list