Hi everyone,
I was looking for a way to generate Code-128 barcodes in C++ and came across grandzebu's website. Since it has no version for C++, I translated the code there to C++ myself. At first I had trouble getting it to work (mainly because of signedness of characters in std::string which broke the checksum calculation)

Because of that problem, I had decided to completely dissect the code. I noticed that the whole logic of that main-loop is pretty twisted, because it basically goes back and forth between doing two very different things (table-B and table-C) and has very complicated transitions between the corresponding code-parts.
I put the code for table-C into a different function, so the transitions work by calling the function and returning from it. This turned the 35-line loop into two 4-line loops.

I was so pleased with the result, that I translated the code to Java and JavaScript (although the missing call-by-reference forces you to do a few tricks there). The JavaScript version runs fine on Chrome for Linux, Chrome for Windows, Firefox on Windows and Edge on Windows (not on Internet Explorer 11 though, because IE11 doesn't support WOFF2 WebFonts)