208 questions
3
votes
1
answer
228
views
Encounter a problem that print wide_character in C
Here is my code:
#include "snake.h"
void SetPos(short x, short y)
{
//获得标准输出设备的句柄
HANDLE houtput = NULL;
houtput = GetStdHandle(STD_OUTPUT_HANDLE);
//定位光标的位置
COORD pos =...
3
votes
3
answers
131
views
behaviour of fprintf when 'ls' format specifier is used with precision set for printing string of wide characters
In the C standard's C17 draft N2176 document, at 7.21.6.1.8, it says that
If no precision is specified, the array shall contain a null wide character. If a precision is specified, no more than that ...
1
vote
1
answer
206
views
Adding wide character support breaks ncurses menu
I'm currently trying to create an ada program (this will be relevante later on) with a basic TUI.
To do so, I'm using ncurses, and more specifically, I'm interfacing with C as the ada bindings, ...
-1
votes
1
answer
203
views
NCURSESW - Unable to use addwstr function to print out unicode characters outside of standard ASCII
I am trying to make a simple game using the ncursesw library which I am basically a complete noob at. I got the library working and I am now able to compile programs successfully with it. Now I am ...
0
votes
1
answer
260
views
How to I get the contents from a wchar_t array into a LPWSTR?
I found a very old post, which gives the answer as:
LPCWSTR is a pointer to a const string buffer. LPWSTR is a pointer to a non-const string buffer. Just create a new array of wchar_t and copy the ...
4
votes
2
answers
246
views
Problem with printing wide character in c
Hello I want to print the letter 'å' which is 131 in extended ascii and as far as I can see has UTF-8 code 00E5 and 0x00E5 in UTF-16. However, in the code below the program prints 'Õ' which is not ...
0
votes
2
answers
648
views
print unicode character on linux using gcc
I'm trying to print wchar_t string to terminal but the string doesn't show up or it appears as unreadable characters.
I tried on XUbuntu 22.04 and gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0 and you ...
-1
votes
1
answer
314
views
Wide string command line arguments in C
I'm writing a program that what it does first, is to retrieve the first command line argument (which should be a process name), and find the corresponding PID of the process.
Here's how I do it:
in ...
0
votes
1
answer
106
views
Do I need to free memory after call to WriteConsoleW?
I am writing a function which prints a formatted string in a Windows console. It takes a simple C string which is a single byte string, converts it into a wide string for the Windows O.S., sends it to ...
1
vote
1
answer
426
views
Capture Unicode command line output
I have a procedure to capture a hidden Command Prompt window and display the output in a TMemo. This is the same/similar code that is posted all over the internet and Stack Overflow:
var
Form1: ...
-1
votes
1
answer
166
views
wchar_t user input with spaces
Im currently using wchar_t for a username, however, I'm having an issue when the username contains a space when using std::wcout as it will just get the first word typed.
I am aware of getline for ...
0
votes
3
answers
206
views
I have difficulties with putwchar() in c
Certainly, my problem is not new...., so I apologize if my error is simply too stupid.
I just wanted to become familiar with putwchar and simply wrote the following little piece of code:
#include <...
0
votes
0
answers
172
views
Parse non-ascii string from argv in 'main' function C++
I am writing a console program that processes files passed by the user as launch arguments
(reads, processes in a certain way, writes to other files).
The problem is that file paths can contain ...
0
votes
1
answer
234
views
Issues getting UuidToStringW to generate a proper UUID string
Looking at replacing some id's in our main code base with UUIDs so that the ids can be used with multiple instances of our software. Before adding this functionality, I thought I would check out how ...
4
votes
0
answers
148
views
How does the Windows terminal know if I wrote a wide character or a normal character?
I used _setmode(_fileno(stdout), _O_U8TEXT).
I am trying to understand how wprintf() differs from printf(), so I am trying to understand the difference betweem putc() and fputwc(). I thought the ...
0
votes
1
answer
107
views
How to deal with wide and narrow buffers in c?
According to embarcadero docs we can use different Format Specifier to output a buffer to the console in my case I have a function that reads from a stream and outputs to the console but sometimes the ...
0
votes
1
answer
59
views
How to use ReadFile with multibyte codes
How to use ReadFile to read a buffer as wchar_t array and then output it to the console
DWORD read_output()
{
BOOL success = FALSE;
DWORD dwRead;
HANDLE handle = CreateFileW(L"data....
0
votes
0
answers
217
views
How to deal with wide-character directory entries in C?
I have looked up various methods of converting wide strings to single-byte characters, but am unsure how to approach the char d_name[260] field of a struct dirent entry pertaining to a file with a ...
1
vote
1
answer
308
views
Only some unicode characters work with ncurses
I'm using ncurses 6.3, installed on OSX 12.0.1. My program is:
#define NCURSES_WIDECHAR 1
#include <locale.h>
#include <ncurses.h>
int main() {
setlocale(LC_ALL, "");
...
1
vote
1
answer
174
views
Cant compare wide characters | C++
If I read special characters from a file and then try to compare them (like with an if) it doesn't recognize them.
std::wstring c;
std::wifstream file;
file.open("test.txt");
...
0
votes
1
answer
347
views
Printing wide character literals in C
I am trying to print unicode to the terminal under linux using the wchar_t type defined in the wchar.h header. I have tried the following:
#include <wchar.h>
#include <stdio.h>
int main(...
1
vote
2
answers
121
views
Wide charectar in print for some Farsi text, but not others
I'm using Google Translate to convert some error codes into Farsi with Perl. Farsi is one such example, I've also found this issue in other languages---but for this discussion I'll stick to the ...
0
votes
2
answers
989
views
Extracting file from zip using wide string file path in C++
How can you read a file from a zip by opening the zip with a wide string file path? I only saw libraries and code examples with std::string or const char * file paths but I suppose they may fail on ...
0
votes
1
answer
426
views
Strange unicode error when converting Chinese wide strings to regular strings in C++
Some of my Chinese software users noticed a strange C++ exception being thrown when my C++ code for Windows tried to list all running processes:
在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。
Translated to ...
0
votes
3
answers
648
views
Effect of Wide Characters/ Strings on a C Program
Below is an excerpt from an old edition of the book Programming Windows by Charles Petzold
There are, of course, certain disadvantages to using Unicode. First and foremost is that every string in ...
1
vote
3
answers
929
views
Duplicating wide-character string
I am trying to create an application in which I have a function where I am trying to duplicate a wide character string. I am currently using _wcsdup(), since it is a Windows application and everything ...
1
vote
0
answers
107
views
WCHAR not functioning properly in linux
I am trying to use wstring in a C++ program which is as follows:-
#include<iostream>
using namespace std;
const wstring NAME = L"STACKOVERFLOW";
int main()
{
wcout<<NAME;
}
...
1
vote
1
answer
752
views
Python Curses, reading wide character's attribute from screen
The problem I'm trying to solve is to get a couple ch,att representing the character and the associated attribute currently displayed at some given position.
Now, when the displayed character is not a ...
0
votes
4
answers
969
views
C Macro should expand as char* in one place and wchar* in another place with L character
I am looking for help with writing a C macro that expands into char* macro in one place and wchar_t* macro in another place.
Eg:
#define MACRO_STRING "Macro String"
to atomic section with ...
2
votes
1
answer
757
views
Converting a hex string representation of a widechar codepoint to a widechar in Delphi
I am having trouble converting text within an edit box to a WideChar. This is being used in code for printing emoji characters.
If I manually set the WideChar values like the following it works
Emoji[...
-2
votes
2
answers
997
views
Cannot use wide strings in C/C++ Visual Studio, even though it works in CodeBlocks using MinGW
I'm trying to use the Windows API in Visual Studio 2019. The problem is that when I'm trying to create a wide string, using something like this: L"Hello World!", I get an error: 'L': ...
0
votes
0
answers
35
views
how to enable HAVE_FWPRINTF in gettext-runtime\intl\printf.c?
I am trying to return locale names on windows system. For this I need to use swprintf() as follow in the code.
#include <wchar.h>
#include <shlwapi.h>
#include <langinfo.h>
...
/* ...
0
votes
1
answer
1k
views
ncurses get_wch() function undeclared
I try to check the output of the get_wch function from the ncurses library, on Archlinux install.
But when I call the function, I got this GCC error:
main.c:6:15: warning: implicit declaration of ...
0
votes
1
answer
312
views
Print utf8 wchar_t in windows console
I'm running CodeBlocks in Windows 10 and even after following some of the indications found on SO, I did not manage to print in cosole utf8 chars.
_setmode(_fileno(stdout), 0x00020000); // _O_U16TEXT
...
1
vote
4
answers
1k
views
Append extra null char to wide string
Some Win32 API structures require to concatenate an extra null character to a string, as in the following example taken from here:
c:\temp1.txt'\0'c:\temp2.txt'\0''\0'
When it comes to wide strings, ...
2
votes
1
answer
135
views
Why can't I marshal UCS-4 strings properly in C#?
I am trying to marshal a hid_device_info struct in C#, but I can't figure out how to translate the wchar_t* strings to managed C# strings. I have tried all possible values in the MarshalAs attribute, ...
0
votes
0
answers
244
views
std::wofstream gets broken in binary mode in GCC but works in MSVC
The following piece of code produces a file with a single byte when compiled in MSVC, but when compiled by GCC 8.3 it produces an empty file.
std::wofstream out("tmpUTF16BrokenBOMFile.txt", ...
1
vote
1
answer
67
views
Can't read wstrings containing → and print inputted unicode characters
I'm writing a program which has to work with the characters ↓, → and ¬. I'm having trouble with reading and printing the characters. This works just fine:
#include <iostream>
#include <string&...
0
votes
1
answer
71
views
Long to wide based on different columns in R
I have the following long data that I want to transform to wide data based on a different column
id_1<-c(1,2,3,4,4,4,4,5,5,5,5,5,6)
h06b<-c(1,1,1,1,2,3,4,1,2,3,4,5,1)
h07<-c(1,2,3,4,5,6,7,8,9,...
1
vote
1
answer
100
views
is there an R code for converting from wide to long when you have more than 1 unique id in R?
I have the following data that i want to convert from wide to long.
id_1<-c(1,2,2,2)
s02.0<-c(1,1,4,7)
s02.1<-c(2,2,5,8)
s02.2<-c(NA,3,6,NA)
id_2<-c(1,1,2,3)
df1<-data.frame(id_1,s02....
0
votes
1
answer
97
views
is there an R code for the following data wrangling and transformation
I have the following data set
id<-c(1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4)
s02<-c(001,002,003,004,001,002,003,004,005,001,002,003,004,005,006,...
3
votes
1
answer
370
views
Why does printing this wide character string crash on windows?
I stumbled upon a problem while going through some unit tests, and I am not entirely sure why the following simple example crashes on the line with sprintf (Using Windows with Visual Studio 2019).
#...
0
votes
1
answer
453
views
WideCharToMultiByte not converting Japanese on English OS
I need to convert file names from System.String into std::string. I am using both Japanese and English file names.
For English file names, there is no issue.
Only Japanese file names are not ...
0
votes
1
answer
168
views
g++ wchar_t string litteral is not of expected type [duplicate]
(sorry. might not be the most relevant question...)
According to https://en.cppreference.com/w/cpp/language/string_literal:
""" Wide string literal. The type of a L"..." string literal is const ...
1
vote
1
answer
192
views
Get file translation mode of stdout
Function int _setmode(int, int) allows to switch stdout among ASCII and UTF (wide) modes.
Is there a function to read the current translation mode of stdout? Something like _getmode? In C# there is ...
2
votes
1
answer
137
views
Wide-character version of _memccpy
I have to concatenate wide C-style strings, and based on my research, it seems that something like _memccpy is most ideal (in order to avoid Shlemiel's problem). But I can't seem to find a wide-...
6
votes
1
answer
555
views
Why is © (the copyright symbol) replaced with (C) when using wprintf?
When I try to print the copyright symbol © with printf or write, it works just fine:
#include <stdio.h>
int main(void)
{
printf("©\n");
}
#include <unistd.h>
int main(void)
{
...
2
votes
0
answers
182
views
Unreadable memory validation
I've got an wide char string , where the content of it is read from a rich edit control. Because the corrupted content of strKeyW, application lately crashes ; and unfortunately I can't check why ...
1
vote
1
answer
815
views
Create file in a specific Unicode path
I want to create a file with the given location path that contains Unicode characters. I've tried the below code but after compiling my code no file is generated.
wchar_t path = (wchar_t)"D:/File/ফো...
1
vote
1
answer
2k
views
Does `std::wregex` support utf-16/unicode or only UCS-2?
With c++11 the regex library was introduced into the standard library.
On the Windows/MSVC platform wchar_t has size of 2 (16 bit) and wchar_t* is normally utf-16 when interfacing with the system/...