المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : tstring?



C++ Programming
10-21-2009, 01:11 AM
I'm trying to write my code independent of text encoding, which is a trivial matter for c-strings, however I'm not sure what the appropriate solution is for std::string...

At the moment I'm using the following...

#ifdef UNICODE
typedef tstring wstring;
#else
typedef tstring string;
#endif


this works for most cases, however I'm stuck when using stringstreams - I often manipulate strings with them and get the result using stringstream::str() - but of course that wont work if I'm using my tstrings because there's no appropriate conversion available. I guess my questions here are, A) is the above snippet the best way to do it, B) is there already a tstring defined somewhere that I may have missed, and C) how do I get stringstream::str() to return an encoding-independant string?