stdlib - UTF8 console i/o in Windows, other crucial fixes, functional
area headers
https://github.com/alf-p-steinbach/stdlib
stdlib is a pure header library that provides
• fixes for some standard library issues, including that
<stdlib/console_io.hpp> makes Windows console i/o work for international
text such as Norwegian (more precisely the Basic Multilingual Plane of
Unicode is supported for the iostreams objects such as cout), with
narrow text encoded as UTF-8;
• C++ library header wrappers for all C++ standard library headers, e.g.
you can just include <stdlib/iostream.hpp> where you want the <iostream>
header with the Windows console i/o fix, plus some;
• C library header wrappers, e.g. <stdlib/math.hpp> which for maximal
portability includes both <cmath> and <math.h> for you, and ditto for
the other C library headers;
• functional area headers for the C++ standard library, e.g. just
include <stdlib/io.hpp> to get all the C++ iostreams headers plus the C
standard library’s i/o headers, more precisely all headers in this
category mentioned in the header overview at
cppreference.com; and
• extensions such as <stdlib/byte_to_wide_converter.hpp>, which provides
the class that’s used for narrow and wide encoding conversion in the
Windows console i/o fix. Most of the extensions are part of the library
implementation anyway, so they’re provided in a reusable form in the
public interface. Those that are not directly used in the current
library code, are provided for completeness.
Other fixes & nice-to-haves include
• support for de facto standard <math.h> constants such as M_PI;
• support for the C++ standard’s alternative keywords such as and, or
and not, in Visual C++;
• random seed for C++11 random number generation with g++;
• support for output of something that converts implicitly to wchar
const*, on a wide stream, corresponding to how something that converts
implicitly to char const* can be output an a narrow stream;
• setting the default locale in C and C++ to the user’s native locale,
which makes the wide iostreams work for international text in *nix-land;
• setting UTF-8 as the basic execution character set (i.e. for narrow
literals) in Visual C++; and just because it’s nice to have in a
portable way,
• support for ANSI escape sequences, e.g. to produce colored console
text or move the text cursor on the screen, in Windows 10 and later.
Cheers!, & enjoy,
- Alf