Re: Append wchar enumeration to string

2010-11-22 Thread Steven Schveighoffer
On Sun, 21 Nov 2010 05:58:30 -0500, Nrgyzer nrgy...@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

Append wchar enumeration to string

2010-11-21 Thread Nrgyzer
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

Re: Append wchar enumeration to string

2010-11-21 Thread Simen kjaeraas
Nrgyzer nrgy...@gmail.com wrote: But... when I try the following: char[] myString = Currency: ~ cast(char) CURRENCY.DOLLAR It works, but not for all currencies. What can I do to support all currencies? The problem is that not all UTF-8 code points fit in one char. I would recommend in this

Re: Append wchar enumeration to string

2010-11-21 Thread Nrgzyer
When I use an string enumeration, I get the following error (dmd1): CURRENCY base type must be of integral type, not char[]

Re: Append wchar enumeration to string

2010-11-21 Thread Simen kjaeraas
Nrgzyer nrgz...@gmail.com wrote: When I use an string enumeration, I get the following error (dmd1): CURRENCY base type must be of integral type, not char[] Ah, you're using D1. Well, a solution would be to use dchar[] instead of char[]. -- Simen

Re: Append wchar enumeration to string

2010-11-21 Thread Nrgyzer
But for enums I can't use char[] as basetype and when I use cast(dchar) or cast(wchar) I also get Error: incompatible types for

Re: Append wchar enumeration to string

2010-11-21 Thread Nrgyzer
I solved the problem by using toUTF8 from std.utf but I think it's a dirty solution because I have to cast wchar to wchar[] because a simple toUTF8(CURRENCY.DOLLAR) matches wchar[] and dchar[] signatures.