The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,876 other followers

Archive for the ‘C++’ Category

UTF-8 support for single byte character sets is beta in Windows and likely breaks a lot of applications not expecting this (via Unicode in Microsoft Windows: UTF-8 – Wikipedia)

Posted by jpluimers on 2018/12/04

Uh-oh: [WayBack] Unicode in Microsoft Windows: UTF-8 – Wikipedia:

Microsoft Windows has a code page designated for UTF-8, code page 65001. Prior to Windows 10 insider build 17035 (November 2017),[7] it was impossible to set the locale code page to 65001, leaving this code page only available for:

  • Explicit conversion functions such as MultiByteToWideChar
  • The¬†Win32 console¬†command¬†chcp 65001¬†to translate stdin/out between UTF-8 and UTF-16.

This means that “narrow” functions, in particular¬†fopen, cannot be called with UTF-8 strings, and in fact there is no way to open all possible files using¬†fopen¬†no matter what the locale is set to and/or what bytes are put in the string, as none of the available locales can produce all possible UTF-16 characters.

On all modern non-Windows platforms, the string passed to¬†fopen¬†is effectively UTF-8. This produces an incompatibility between other platforms and Windows. The normal work-around is to add Windows-specific code to convert UTF-8 to UTF-16 using¬†MultiByteToWideChar¬†and call the “wide” function.[8]¬†Conversion is also needed even for Windows-specific api such as¬†SetWindowText¬†since many applications inherently have to use UTF-8 due to its use in file formats,¬†internet protocols, and its ability to interoperate with raw arrays of bytes.

There were proposals to add new API to portable libraries such as¬†Boost¬†to do the necessary conversion, by adding new functions for opening and renaming files. These functions would pass filenames through unchanged on Unix, but translate them to UTF-16 on Windows.[9]¬†This would allow code to be “portable”, but required just as many code changes as calling the wide functions.

With insider build 17035 and the April 2018 update (nominal build 17134) for Windows 10, a “Beta: Use Unicode UTF-8 for worldwide language support” checkbox appeared for setting the locale code page to UTF-8.[a]¬†This allows for calling “narrow” functions, including¬†fopen¬†and¬†SetWindowTextA, with UTF-8 strings. Microsoft claims this option might break¬†some¬†functions (a¬†possible¬†example is¬†_mbsrev[10]) as they were written to assume multibyte encodings used no more than 2 bytes per character, thus until now code pages with more bytes such as¬†GB 18030¬†(cp54936) and¬†UTF-8¬†could not be set as the locale.[11]

  1. Jump up^¬†[WayBack]¬†“UTF-8 in Windows”.¬†Stack Overflow. Retrieved¬†July 1,¬†2011.
  2. Jump up^¬†[WayBack]¬†“Boost.Nowide”.
  3. Jump up^ [WayBack]
  4. Jump up^¬†[WayBack]¬†“Code Page Identifiers (Windows)”.¬†

Via¬†[WayBack] Microsoft Windows Beta UTF-8 support for Ansi API could break things. Wiki Article of the Change… – Tommi Prami – Google+

Related, as handling encoding is hard, especially if it is changed or not your default:


Posted in .NET, C, C++, Delphi, Development, Power User, Software Development, Windows, Windows 10 | 2 Comments »

Finding your program with an “Access Denied” (Error code 5) after lunch break…

Posted by jpluimers on 2018/10/24

Via: [WayBack] I just returned from lunch break and found my program faulted with an “Access Denied” (Error code 5) error in a call to Mouse.GetCoursorPos and was wond… – Thomas Mueller (dummzeuch) – Google+:

All of [WayBack]¬†GetCursorPos, [WayBack]¬†GetCursorInfo and [WayBack] GetKeyState can cause an “Access Denied” (Error code 5) when they do not have permission for the current desktop (for instance the logon desktop when a screen-saver has kicked in).

Solution: write a wrapper around it then [WayBack] patch calls going to the original into the patch [WayBack] delphi – Explain errors from GetKeyState / GetCursorPos – Stack Overflow


Posted in .NET, C#, C++, Delphi, Development, Software Development, Windows Development | Leave a Comment »

Not just C++: Thoughts on Dealing with Signed/Unsigned Mismatch – IT Hare on Soft.ware

Posted by jpluimers on 2018/10/02

[WayBack] C++: Thoughts on Dealing with Signed/Unsigned Mismatch – IT Hare on Soft.ware.

I have seen things like this happen in way to many places, not just C/C++:

static_assert( -1 < 1U );//fails!

Take away:

Never ever use explicit casts merely to get rid of warnings (whether signed/unsigned or otherwise)

A way to set various C/C++ compilers apart: [WayBack] GitHub Рshafik/determine_c_or_cpp: Determine programatically C from C++ as well as various versions

Via: [WayBack] C++: Thoughts on Dealing with Signed/Unsigned Mismatch РIT Hare on Soft.ware: Kevlin Henney РGoogle+


Posted in C, C++, Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Links to various Visual C++ Redistributable Packages for Visual Studio downloads (arm/x64/x86 when available)

Posted by jpluimers on 2018/01/17

Link archive so I know how to get the 64-bit ARM, 32-bit Win32/x86 and 64-bit Win64/x64 downloads for the Visual C++ Redistributable files.

Note the various names of pages and files Microsoft uses.


Posted in C++, Development, Software Development, Visual Studio C++ | Leave a Comment »


Posted by jpluimers on 2018/01/01

It is a lot (~300 megabyte compressed download!), but worth it.

Here are the links:

And the quote from¬†[WayBack] LAUNCHED … – Joe C. Hecht – Google+


337 MB of source and utils in 2,308 Files, 910 Folders before you build (not counting 3rd party source UberBuild downloads).

It’s a start, with much to come.It will get easier now that UberBuild is clean.

I will be updating the docs and website in the next few days.

Special thanks …

I already see room for improvement (such as a setup screen for extra compilers such as Delphi and Free Pascal to keep folks out of shell scripts and from hunting for help in the documentation).


Posted in *nix, C, C++, Delphi, Development, Linux, Power User, Software Development, Windows | 3 Comments »

%d bloggers like this: