wchar

Pass a function pointer from C++ to be called by C# - Arguments of functions include a wide char string (LPCWSTR)

和自甴很熟 提交于 2019-12-18 06:58:02
问题 I am writing a C# library to be used by native C++ application. I am using C++/CLI as the Interoperability mechanisim. I require to pass a callback function from C++ to C# (using C++/CLI as the intermediate layer). C# library needs to call the C++ function with a zero terminated string of wide characters; i.e. the prototype of the callback function is Func(LPCWSTR pszString); There are other parameters but they are immaterial for this discussion. I searched net and found Marshal

Conversion from char * to wchar* does not work properly

喜夏-厌秋 提交于 2019-12-13 05:53:07
问题 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"

how implement function work as sprintf use wchar for parameter?

↘锁芯ラ 提交于 2019-12-13 03:02:07
问题 l used ANDROID NDK 。so l want to format something。just use sprintf,but l can not use it with wchar_t. is there some helps for me? 回答1: You probably want swprintf and friends, assuming Android has it like Posix and Linux systems. Glib (from GTK) has functions for unicode manipulation and for string utilities. I believe you should be able to make it work on Android. 回答2: In Android OS NDK versions before 5.0 ("Lollipop"), the sprintf() does not support the "%ls" (wchar_t pointer) format

Multi-Byte UTF-8 in Arrays in C++

て烟熏妆下的殇ゞ 提交于 2019-12-12 13:14:31
问题 I have been having trouble working with 3-byte Unicode UTF-8 characters in arrays. When they are in char arrays I get multi-character character constant and implicit constant conversion warnings, but when I use wchar_t arrays, wcout returns nothing at all. Because of the nature of the project, it must be an array and not a string. Below is an example of what I've been trying to do. #include <iostream> #include <string> using namespace std; int main() { wchar_t testing[40]; testing[0] = L'

Difference and conversions between wchar_t for Linux and for Windows

你。 提交于 2019-12-12 05:58:35
问题 I understand from this and this thread that in Windows, wchar_t is 16-bit & for Linux, wchar_t is 32 bit. I have a client-server architecture (using just pipes - not sockets)- where my server is Windows based and client is Linux. Server has a API to retrieve hostname from client. When the client is Windows based, it could just do GetComputerNameW and return Wide-String. However, when the client is Linux based, things get messy. As a first naive approach, I used mbstowcs() hoping to return

Compare C-string of types char* and wchar_t* [closed]

[亡魂溺海] 提交于 2019-12-11 08:34:11
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have a key like: wchar_t key[] = L"764frtfg88fgt320nolmo098vfr"; and a char* row[i] returned by a query from a Database. I'd like to compare my Key with row[i] . I tried with wcscmp (key,row[i]) != 0) but it gives me an error. Any suggestions ? 回答1: This might help: C++ Convert string (or char*) to wstring (or

Compare WCHAR String with Const Char in C?

只愿长相守 提交于 2019-12-11 05:34:06
问题 I have written a code in C which will use the Process32First() API to get information about the process. All the information is stored in the PROCESSENTRY32 structure defined here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684839%28v=vs.85%29.aspx pe32 is the name of the PROCESSENTRY32 structure. process name will be: pe32.szExeFile I can print it this way: _tprintf(TEXT("Process name: %s\n"),pe32.szExeFile); now, I want to compare the process name with a specific process like

How to concat an int to a wchar_t* in C++?

爷,独闯天下 提交于 2019-12-10 18:38:32
问题 I have to create and write on N files, everyone must have an integer ending to identificate it. This is my piece of code: for(int i=0; i<MAX; i++) { uscita.open("nameFile"+i+".txt", ios::out); uscita << getData() << endl; uscita.close(); } And that's what I would like to find in my directory after execution: nameFile0.txt nameFile1.txt nameFile2.txt ... nameFileMAX.txt The problem of the above code is that I get the compilin' error: error C2110: '+' Impossible to add two pointers If I try to

Cannot convert 'const char*' to 'WCHAR*' in argument passing

两盒软妹~` 提交于 2019-12-10 04:19:32
问题 I have documentation where written that username, IP and password must be const char* and when I'm putting varaibles in const char , I'm getting this error message. This is my code: #include <cstdlib> #include <iostream> #include <stdio.h> #include <windows.h> using namespace std; typedef int (__cdecl *MYPROC)(LPWSTR); int main() { HINSTANCE hinstDLL; MYPROC ProcAdd; hinstDLL = LoadLibrary("LmServerAPI.dll"); if(hinstDLL != NULL){ ProcAdd = (MYPROC) GetProcAddress(hinstDLL,"LmServer_Login");

What is the proper way to convert an int to wchar_t?

限于喜欢 提交于 2019-12-08 05:44:06
问题 Say you have "methods" int Read(...) { unsigned char Byte = 0; if(!ReadFile(.., &byte, 1,...)) return -1; return Byte; } int ReadBlock(LPWSTR buffer, int cchBuffer ...) { int c = 0; int cnt = 0; do { if( (c=Read(...)) != -1 ) buffer[num++] = c; // Here. } while( num < ccBuffer ); return cnt; } What is the proper way to get that int correctly to WCHAR? 回答1: convert char <= => wchar in windows: MultiByteToWideChar WideCharToMultiByte in linux: mbsrtowcs wcsrtombs 回答2: Use mbstowcs (multibyte