問題タブ [fedora12]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - Conversion from char * to wchar* does not work properly
I'm getting a string like: "aña!a¡a¿a?a"
from the server so I decode it and then I pass it to a function.
What I need to do with the message is something like loading paths depending the letters.
The header of my function is: void SetInfo(int num, char *descr[4])
so it receives one number and an array of 4 chars (sentences). To make it easier, let's say I just need to work only with descr[0].
When I debug and arrive there to SetInfo(), I get the exact message in the debugg view: "aña!a¡a¿a?a"
so until here is all ok.
Initially, the info I was receiving on that function, was a std::wstring so all my code working with that message was with wstrings and strings but now what I receive is a char as shown in the header. The message arrived until here ok, but if I want to work with it, then I can't because if I debug and see each position of Descr[0] then I get
so I tried converting char* to wchar* with a code found here:
But then the debugger shows me that wa
has:
wa wchar_t * 0x185d4be8 L"a-\uffffffff刯2e2e牵6365⽳6f73歯6f4c楲6553䈯736f獵6e6f档6946琯7361灭6569湰2e6f琀0067\021ᡰ9740슃b8\020\210=r"
which I suppose that is incorrect (I'm supossing that I have to see the same initial message of "aña!a¡a¿a?a"
. If this message is fine then I don't know how to get what I need...)
So my question is: how can I get that descr[0][0] = 'a' and descr[0][1] = 'ñ' ?? I can't pass char to wchar (you've already see what I got). Am I doing it wrong? Or is there any other way? I am really stuck on that so any idea will be very apreciated.
Before, when I was working with wstrings (and it worked so fine) I was doing something like this:
where word[i] is the same as descr[0][1] in that case but with wstrings. So with that i knew that this word[i] was the letter 'ñ'. Maybe this helps to understand what I'm doing
(btw...I'm working on eclipse, on linux. )