wchar-t

how to convert char array to wchar_t array?

☆樱花仙子☆ 提交于 2019-11-27 06:45:37
问题 char cmd[40]; driver = FuncGetDrive(driver); sprintf_s(cmd, "%c:\\test.exe", driver); I cannot use cmd in sei.lpFile = cmad; so, how to convert char array to wchar_t array ? 回答1: From MSDN: #include <iostream> #include <stdlib.h> #include <string> using namespace std; using namespace System; int main() { char *orig = "Hello, World!"; cout << orig << " (char *)" << endl; // Convert to a wchar_t* size_t origsize = strlen(orig) + 1; const size_t newsize = 100; size_t convertedChars = 0; wchar_t

Display wchar_t using ncurses

做~自己de王妃 提交于 2019-11-27 06:38:25
问题 i'm currently working on a C++ project in which I need to display some extended characters (wchar_t). The main problem is that, even if it works fine in C (using wprintf ), it doesn't work in c++ using mvwaddwstr or waddwstr . Of course, i've set the locale like that: setlocale(LC_ALL, ""); , and nothing is displayed. Does someone got this problem before, or has an idea about that? Thanks. Here is the code: struct charMap { int x; int y; wchar_t value }; int i, x, y; wchar_t str[2]; struct

How do I convert wchar_t* to std::string?

為{幸葍}努か 提交于 2019-11-27 05:51:08
问题 I changed my class to use std::string (based on the answer I got here but a function I have returns wchar_t *. How do I convert it to std::string? I tried this: std::string test = args.OptionArg(); but it says error C2440: 'initializing' : cannot convert from 'wchar_t *' to 'std::basic_string<_Elem,_Traits,_Ax>' 回答1: You could just use wstring and keep everything in Unicode 回答2: std::wstring ws( args.OptionArg() ); std::string test( ws.begin(), ws.end() ); 回答3: You can convert a wide char

Outputting unicode characters in windows terminal

自古美人都是妖i 提交于 2019-11-27 04:47:37
问题 Over the past week I've been working on a roguelike game in C++ along with a friend. Mostly too learn the language. I'm using: pdcurses Windows 7 Visual studio C++ To output wchar_t 's wherever I want to in the console. I have succeeded in otuputting some unicode characters such as \u263B (☻), but others such as \u2638 (☸) will just end up as question marks(?). Here's the relevant code I use for output. // Container of room information struct RoomInfo { wchar_t * layout; int width; int height

I want to convert std::string into a const wchar_t *

筅森魡賤 提交于 2019-11-27 03:48:39
Is there any method? My computer is AMD64. ::std::string str; BOOL loadU(const wchar_t* lpszPathName, int flag = 0); When I used: loadU(&str); the VS2005 compiler says: Error 7 error C2664:: cannot convert parameter 1 from 'std::string *__w64 ' to 'const wchar_t *' How can I do it? Matt Dillard If you have a std::wstring object, you can call c_str() on it to get a wchar_t* : std::wstring name( L"Steve Nash" ); const wchar_t* szName = name.c_str(); Since you are operating on a narrow string, however, you would first need to widen it. There are various options here; one is to use Windows' built

How to change wchar.h to make wchar_t the same type as wint_t?

≡放荡痞女 提交于 2019-11-26 23:46:46
问题 wchar_t is defined in wchar.h Currently, if the developers want to use only wchar_t , they can not do this without getting type conversion warnings from the compiler. If wchar_t will be made the same type as wint_t , it will be good for both parties. The developers who want to have both wint_t and wchar_t in their programs (for example if they want their code to be compiled not only under glibc) can do this without getting compiler warnings. The developers who want to use only wchar_t (to

How to convert concatenated strings to wide-char with the C preprocessor?

和自甴很熟 提交于 2019-11-26 17:07:19
问题 I am working on a project where I have many constant strings formed by concatenation (numbers, etc.). For example, I have a LOCATION macro that formats __FILE__ and __LINE__ into a string that I can use to know where I am in the code, when printing messages or errors: #define _STR(x) # x #define STR(x) _STR(x) #define LOCATION __FILE__ "(" STR(__LINE__) ")" So, this would format a location like "file.cpp(42)". The problem is when I try to convert the result to a wide-string: #define _WIDEN(x)

How I can print the wchar_t values to console?

橙三吉。 提交于 2019-11-26 13:36:47
Example: #include <iostream> using namespace std; int main() { wchar_t en[] = L"Hello"; wchar_t ru[] = L"Привет"; //Russian language cout << ru << endl << en; return 0; } This code only prints HEX-values like adress. How to print the wchar_t string? Edit: This doesn’t work if you are trying to write text that cannot be represented in your default locale. :-( Use std::wcout instead of std::cout . wcout << ru << endl << en; Konrad Can I suggest std::wcout ? So, something like this: std::cout << "ASCII and ANSI" << std::endl; std::wcout << L"INSERT MULTIBYTE WCHAR* HERE" << std::endl; You might

How I can print the wchar_t values to console?

不问归期 提交于 2019-11-26 03:41:40
问题 Example: #include <iostream> using namespace std; int main() { wchar_t en[] = L\"Hello\"; wchar_t ru[] = L\"Привет\"; //Russian language cout << ru << endl << en; return 0; } This code only prints HEX-values like adress. How to print the wchar_t string? 回答1: Edit: This doesn’t work if you are trying to write text that cannot be represented in your default locale. :-( Use std::wcout instead of std::cout . wcout << ru << endl << en; 回答2: Can I suggest std::wcout ? So, something like this: std:

WChars, Encodings, Standards and Portability

泪湿孤枕 提交于 2019-11-26 01:24:06
问题 The following may not qualify as a SO question; if it is out of bounds, please feel free to tell me to go away. The question here is basically, \"Do I understand the C standard correctly and is this the right way to go about things?\" I would like to ask for clarification, confirmation and corrections on my understanding of character handling in C (and thus C++ and C++0x). First off, an important observation: Portability and serialization are orthogonal concepts. Portable things are things