C++ Convert any character sequence to any standard string

Four standard char types can be transformed to each other
Four standard char types can be transformed to each other

(Note: this is the second part of C++ : codecvt deprecated. Panic? )

Update

Due to popular acclaim I have made and published a stand alone and fully functional code described in this post. It is in the form of Github Gist here.

It is also updated and optimized. Enjoy …

Update

This is not a foreign language translator or some such code.  This is a standard  C++ 17 utility to transform  the core character sets between each other.  The first 127 characters, that is. As a such it is remarkably useful and simple. For full blown, locale aware solutions please look elsewhere, starting from here.  End of update.

Standard C++ std lib, is one very complete and useful library. But there are times when you do realize you can build one or two of very simple utilities on top of it.

Simple but sometimes surprisingly powefull. Continue reading “C++ Convert any character sequence to any standard string”

C++ Windows Unicode Console Output

unicode gone wrong

Update 2019-11-11

Not much has changed in the WINLAND console world. Still, the following code produces no output.

Unless you do spend time digging through this long post or other similar posts elsewhere. Generally doing things, Linux/Mac console developers users, have never heard of.

For example. I have never mentioned ‘u8’ (UTF-8) string literals. That is an iso C++ native way to use UTF-8 encoding of char string literals.

To actually make the above work, you need to do two more “things” as ever: make sure chcp 65001 is executed beforehand, on the same console (in WIN10 it *should* be the default), and of course if not already switch to the font that can show these glyphs.

Yes, to code in a truly portable fashion, I suggest using char8_t as bove.  Alternatively, one can always try a bit more relaxed style:

But be prepared to be surprised by your compiler, at least for a while until it exhibits a full C++20 conformance.

Windows Terminal 1.0

Yes, there is much more I can write about this whole issue, but I decided not to.  Yet. Let’s allow the WIN team leadership to release a stable and bug-free new console subsystem first. Apparently that is “spring 2020”.

Continue reading “C++ Windows Unicode Console Output”

c++ strong types holy grail

Exact types of Fasteners
Exact types of Fasteners type. It is impossible to confuse them with each other.

This is the second installment of an aptly named “c++ strong duck” post. (a title is an act of deliberate sarcasm vs ‘duck typing’ ). If you haven’t before please make a slight detour to that post, for a brief introduction on strong types, as an antidote to “type punning“. Continue reading “c++ strong types holy grail”

One Plugin to end all jQuery Plugins

Meta Plugin
Meta Plugin

Well, I could not resist this catchy title, could I? Perhaps I could. In any case I have this idea and implementation where one jQuery plugin is sort-of-a “socket” (not a network socket, but a socket in the wall) into which you can plug-in your “plugs” which will do standard jQuery related stuff.

Where “standard jQuery related stuff” is either changing the state of the DOM behind, or either using the information from the DOM to do something with it.
Continue reading “One Plugin to end all jQuery Plugins”