convert TDesC8 to Open C string
| Thu, 2008-05-08 08:44 | |
|
Hi, I want to convert my TDesC8 (Symbian string) to std::string (Open C string)! WHY??? Thx the answers! |
|
| Thu, 2008-05-08 08:44 | |
|
Hi, I want to convert my TDesC8 (Symbian string) to std::string (Open C string)! WHY??? Thx the answers! |
|
Forum posts: 152
bakosa,
Your code looks pain wrong for various reasons. First of all, why bother allocating std::string on the heap? Sencondly, std::string is NOT char*, so you can't simply use memcpy on it.
I haven't used STL on Symbian, but I guess the correct way would be:
std::string str(get_episode.PtrZ(), get_episode.Length());Or even
std::string str(get_episode.PtrZ());Obviously, the former is more efficient. As simple as that.
Please see the std::string docs at http://www.sgi.com/tech/stl/basic_string.html
Forum posts: 1134
What confuses me the most is why you think that std::string has anything to do with Open C...
std::string is C++ STL...
Also, from what you describe, I doubt you are using a TDesC8, sounds more like a TDesC16 with the every-second-byte-being-zero thing.