wchar-t

Inconsistency in definitions of fputwc(), putwc() and putwchar() in glibc

拜拜、爱过 提交于 2019-12-02 00:36:41
Why fputwc() , putwc() and putwchar() take argument of type wchar_t instead of wint_t ? This contradicts corresponding non-wide character functions fputc() , putc() and putchar() , which take int , not char . tversteeg That is because wchar_t is required to hold an WEOF value and char is not required to hold an EOF value. For char , the fputc() , putc() and putchar() functions need to accept values which can hold both values in the unsigned char and EOF range, where EOF can be a negative number so a int is required to hold them both. 1 Whereas wchar_t itself is required to hold a WEOF

Comparing 2 wchar_t arrays

笑着哭i 提交于 2019-12-01 17:33:50
I'm sure this is sooo simple but I've come from a c# background where strings are easy and now I am making a small trip into the unmanaged world I am very confused. Essentially I am using EnumDisplayDevices to list the available devices, I want to target a particular adapter so I need to compare DeviceString and DeviceName against some know values to see whether or not I have the right adapter to work on. But I am stumped, I defined the known value as such... wchar_t devName[] = L"Intel(R) HD Graphics Family"; but direct comparison doesn't work - if(devName == theDisplay.DeviceName) strcmp

warning: multi-character character constant [-Wmultichar]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 17:28:38
I want to have an Array of the Greek alphabet and this is what I do: wchar_t pcletters[30] = {'α' , 'ά' , 'β' , 'γ' , 'δ' , 'ε' , 'ζ' , 'η', 'θ' , 'ι' , 'κ' , 'λ' , 'μ' , 'ν','ξ' , 'ο' , 'π' , 'ρ' , 'σ' , 'τ' , 'υ' , 'φ' , 'χ' , 'ψ' , 'ω', 'έ' , 'ή' , 'ί' , 'ό' , 'ύ' , 'ώ'} ; I also include <locale.h> and have a line setlocale(LC_CTYPE, "") . However I get the warning warning: multi-character character constant [-Wmultichar]. Moreover when I get to check if one of this letters is in a user input by doing : if (userword[i] == pcletters[j]) {//do stuff} it does not seem to work. -Why do I get

Comparing 2 wchar_t arrays

走远了吗. 提交于 2019-12-01 17:12:50
问题 I'm sure this is sooo simple but I've come from a c# background where strings are easy and now I am making a small trip into the unmanaged world I am very confused. Essentially I am using EnumDisplayDevices to list the available devices, I want to target a particular adapter so I need to compare DeviceString and DeviceName against some know values to see whether or not I have the right adapter to work on. But I am stumped, I defined the known value as such... wchar_t devName[] = L"Intel(R) HD

Using wsprintf to convert int to wchar_t*

Deadly 提交于 2019-12-01 06:43:49
I'm trying to get a wchar_t* formatted with an int as a parameter. I've Googled a lot but I've only ended up more confused. So, consider this code: int main(int argc, char** argv) { wchar_t buf[16]; wsprintf(buf, L"%d", 5); wprintf(L"[%ls]\n", buf); system("pause"); return 0; }; Having assumed that wchar_t , wsprintf and wprintf are the wide character equivalents of char , sprintf and printf respectively, I expected the above to print [5] , but it prints garbage between [ and ] . What is the correct way to achieve the desired result? And what am I misunderstanding here? (I should clarify that

Solution for missing std::wstring support in Android NDK?

孤者浪人 提交于 2019-12-01 06:04:34
I have a game which uses std::wstring as its basic string type in thousand of places as well as doing operations with wchar_t and its functions: wcsicmp() wcslen() vsprintf(), etc. The problem is wstring is not supported in R5c (latest ndk at the time of this writting). I can't change the code to use std::string because of internationalization and I would be breaking the game engine which is used by many games ... Which options do I have? 1 - Replace string and wstring with my own string classes This would give me better platform independency, but it is ridiculous to reimplement the wheel. I

Using wsprintf to convert int to wchar_t*

元气小坏坏 提交于 2019-12-01 04:20:46
问题 I'm trying to get a wchar_t* formatted with an int as a parameter. I've Googled a lot but I've only ended up more confused. So, consider this code: int main(int argc, char** argv) { wchar_t buf[16]; wsprintf(buf, L"%d", 5); wprintf(L"[%ls]\n", buf); system("pause"); return 0; }; Having assumed that wchar_t , wsprintf and wprintf are the wide character equivalents of char , sprintf and printf respectively, I expected the above to print [5] , but it prints garbage between [ and ] . What is the

How to copy a wchar_t into an NSString?

跟風遠走 提交于 2019-12-01 01:12:49
I'm using stringWithFormat @"%ls" to do it and I only see the first character copied, which makes me think it's still assuming it's a single byte char. Any ideas? Use initWithBytes:length:encoding . You will have to know the encoding that wchar_t uses, I believe it is UTF-32 on Apple platforms. #if defined(__BIG_ENDIAN__) # define WCHAR_ENCODING NSUTF32BigEndianStringEncoding #elif defined(__LITTLE_ENDIAN__) # define WCHAR_ENCODING NSUTF32LittleEndianStringEncoding #endif [[NSString alloc] initWithBytes:mystring length:(mylength * 4) encoding:WCHAR_ENCODING] In general, I suggest avoid using

How to copy a wchar_t into an NSString?

谁说胖子不能爱 提交于 2019-11-30 20:30:59
问题 I'm using stringWithFormat @"%ls" to do it and I only see the first character copied, which makes me think it's still assuming it's a single byte char. Any ideas? 回答1: Use initWithBytes:length:encoding . You will have to know the encoding that wchar_t uses, I believe it is UTF-32 on Apple platforms. #if defined(__BIG_ENDIAN__) # define WCHAR_ENCODING NSUTF32BigEndianStringEncoding #elif defined(__LITTLE_ENDIAN__) # define WCHAR_ENCODING NSUTF32LittleEndianStringEncoding #endif [[NSString

Outputting 'wchar_t*' to an 'ofstream'

强颜欢笑 提交于 2019-11-30 17:29:37
I want to output a text to a file via two pointers that I have declared: wchar_t *Col1="dsffsd", *Col2="sdfsf"; Here is what I have tried: std::ofstream fout; fout.open(NativeDatabasePathHist); fout<<"testing"; fout<<" "<<Col1<<" "<<Col2; fout.close(); And here is what I am getting: testing 113 113 Why is it that when I print Col1 and Col2 , I am getting numbers instead of strings? Dmitriy First, use std::wofstream instead of std::ofstream . Also, use the L prefix on your text string to indicate that your text is wide character text: wchar_t *Col1=L"dsffsd" Since you have written it using wide