Browsed by
Tag: C++

Sending Unicode through Windows Pipes

Sending Unicode through Windows Pipes

Passing unicode data through Windows Pipes sometimes requires special handling to avoid having the pipes scramble the data. We can see this using the cmd prompt and navigating to a path containing unicode characters. The unicode characters cannot be typed, or rendered on screen (showing as question marks instead), though we can use tab complete to type the unicode path. If we are passing data from one program to another through a pipe controlled through a CreateProcess call, we can…

Read More Read More

Mouse Buttons in Win32

Mouse Buttons in Win32

To respond to special mouse button actions in Win32, we need to register the virtual command actions with the callback loop to detect the special mouse button action. For example, to detect forward and backward mouse button actions, we register the APPCOMMAND_BROWSER_FORWARD and APPCOMMAND_BROWSER_BACKWARD events: Should the WM_APPCOMMAND options not work, you might want to look into the VK_* event codes.

Reading wide characters with wifstream

Reading wide characters with wifstream

Should we want to use wifstream to read unicode characters directly from a file, we will encounter an implementation quirk with newline detection in the standard library. Carriage returns and line feed (CR/LF) characters contained within certain characters as a part of a character’s unicode encoding can be mistaken by std::getline for the newline character. This mix-up then causes std::getline to split lines of text in half. wifstream provides a unicode wide character interface to the std library’s file operation…

Read More Read More

C2143 in cstdio

C2143 in cstdio

It is rather interesting when the standard library returns compile errors: This C2143 error is caused by the inclusion of C++ code within a .c file. Renaming the file from *.c to *.cpp will solve the compile error. However, in some circumstances it is not ideal to rename the file. Then the error can be solved by instructing Visual Studio to compile the project as C++ with the /TP option. When we look at the project’s properties, we can see…

Read More Read More