My program needs a lot of ANSI<=>UNICODE conversation so I got the idea to create multitype object which will convert all stuff easier than addinational function and a lot of new/delete. Pseudocode:
class CWchar // char based
{
public:
public static implicit operator wchar_t*(CWchar cw)
{
// converting cw.data to wchar_t
// up to U+FFFF conversion needed
}
public static implicit operator char*(CWchar cw)
{
return cw.data;
}
CWchar& CWchar::operator=(const char* c)
{
data = *c;
return *this;
}
CWchar& CWchar::operator=(const wchar_t* c)
{
//conversion to char* ...
return *this;
}
// add some smart pointers, garbage collector, and leave delete
private:
char* data;
}
Is that really worth coding or should I think about another solution? Maybe there is already done project? Or maybe I am wrong and this idea is bad? Thanks