wstring

How to print wstring in gdb

How can I print wstring in gdb? ...

std::wstring VS std::string

I am not able to understand the differences between std::string and std::wstring. I know wstring supports wide characters such as Unicode characters. I have got the following questions: When should I use std::wstring over std::string? Can std::string hold the entire ASCII character set, including the special characters? Is std::wstring...

Portable wchar_t in C++

Is there a portable wchar_t in C++? On Windows, its 2 bytes. On everything else is 4 bytes. I would like to use wstring in my application, but this will cause problems if I decide down the line to port it. ...

Does C++0x support std::wstring conversion to/from UTF-8 byte sequence ?

I saw that C++0x will add support for UTF-8, UTF-16 and UTF-32 literals. But what about conversions between the three representations ? I plan to use std::wstring everywhere in my code. But I also need to manipulate UTF-8 encoded data when dealing with files and network. Will C++0x provide also support for these operations ? ...

Error C2593: Operator = is ambiguous

typedef map<wstring , IWString> REVERSETAG_CACHE ; REVERSETAG_CACHE::iterator revrsetagcacheiter; . . . wstring strCurTag; strCurTag = revrsetagcacheiter->second; //Error C2593 Error C2593: Operator = is ambiguous Why does the above assignment give this error? It works in VC6. Does not compile in VC9. ...

Bad pointer or link issue when creating wstring from vc6 dll

I got a DLL generated on VC6 and using wstring, and I'm trying to use it in a VC9 project. In this DLL there is a higher level class manipulating wstring, called UtfString. I got everything imported correctly in my project, but when I call: std::wstring test; UtfString uTest(test); it won't link, even if the function prototype is in...

UCS-2LE text file parsing

I have a text file that was created using some Microsoft reporting tool. The text file includes the BOM 0xFFFE in the beginning and then ASCII character output with nulls between characters (i.e "F.i.e.l.d.1."). I can use iconv to convert this to UTF-8 using UCS-2LE for input format and UTF-8 for output format... it works great. My pr...

C++ wstring how to assign from NULL-terminated wchar_t array

Most texts on the C++ standard library mention wstring as being the equivalent of string, except parameterized on wchar_t instead of char, and then proceed to demonstrate string only. Well, sometimes, there are some specific quirks, and here is one: I can't seem to assign a wstring from an NULL-terminated array of 16-bit characters. The...

Qt using std::use_facet with wstring

I need crossplatform code to skip leading spaces for wide string. It's looking that g++ (and Qt obviously) doesn't initialize slots for wide string at all So following code works fine for VC++ but almost g++ fails with bad_cast exception: #include <string> #include <locale> #include <iostream> int main() { typedef std::ctype<std::...

Convert Wstring to CString

i have a variable of Cstring,need to convert it to wstring. ...

.c_str() weirdness? Data changes without rhyme or reason?

I have this simple function: const wchar_t *StringManager::GetWCharTStar(int stringId) { std::wstring originalString = StringManager::GetString(stringId); const wchar_t *retStr = originalString.c_str(); return retStr; } At the second line of that function, I have the correct wchar_t*. However, when I go to return, the dat...

CString vs wstring

I have an MFC application in C++ that uses std::string and std::wstring, and frequently casts from one to the other, and a whole lot of other nonsense. I need to standardize everything to a single format, so I was wondering if I should go with CString or std::wstring. In the application, I'll need to generate strings from a string tabl...

What is the optimal multiplatform way of dealing with Unicode strings under C++?

I know that there are already several questions on StackOverflow about std::string versus std::wstring or similar but none of them proposed a full solution. In order to obtain a good answer I should define the requirements: multiplatform usage, must work on Windows, OS X and Linux minimal effort for conversion to/from platform specif...

String to wstring conversion on OS X

Hello, I'm trying to convert a C++ string to a wstring. I found the following code, that seems to deal with accents, which is what I'm looking for. std::wstring widen(const std::string& s) { std::vector<wchar_t> buffer(s.size()); std::locale loc("fr_FR"); std::use_facet< std::ctype<wchar_t> >(loc).widen(s.data(), s.data() + ...

Conversion from string to wstring is causing ú to lose encoding

The variable filepath which is a string contains the value Música. I have the following code: wstring fp(filepath.length(), L' '); copy(filepath.begin(), filepath.end(), fp.begin()); fp then contains the value M?sica. How do I convert filepath to fp without losing the encoding for the ú character? ...

Confused about C++'s std::wstring, UTF-16, UTF-8 and displaying strings in a windows GUI

I'm working on a english only C++ program for Windows where we were told "always use std::wstring", but it seems like nobody on the team really has much of an understanding beyond that. I already read the question titled "std::wstring VS std::string. It was very helpful, but I still don't quite understand how to apply all of that infor...

C++ Convert string (or char*) to wstring (or wchar_t*)

string s = "おはよう"; wstring ws = FUNCTION(s, ws); How would i assign the contents of s to ws? Searched google and used some techniques but they can't assign the exact content. The content is distorted. ...

C++: Failure to get data through pipe when using wide strings in both programs

Hi, I’m trying to use the following code in C++ on Mac OS X Snow Leopard to get the output of an external program through a pipe. FILE * al = popen("program program.cfg", "r"); string data; char buffer[100]; while (fgets(buffer, 100, al) != NULL) data.append(buffer); cout << "«" << data << "»" << endl; pclose(al); However, no data g...

problem using getline with a unicode file

UPDATE: Thank you to @Potatoswatter and @Jonathan Leffler for comments - rather embarrassingly I was caught out by the debugger tool tip not showing the value of a wstring correctly - however it still isn't quite working for me and I have updated the question below: If I have a small multibyte file I want to read into a string I use the...

How to concatenate 2 LPOLESTR

Hi, i want to concatenate 2 strings in c++, i can't use char*. I tried the following but doesn't work: #define url L"http://domain.com" wstring s1 = url; wstring s2 = L"/page.html"; wstring s = s1 + s2; LPOLESTR o = OLESTR(s); I need a string with s1 and s2 concatenated. Any info or website that explain more about this ? Thanks. ...