I need to convert a string to a barcode Code 128 I found a procedure which converts the original string into the formatted string, including the special characters of the Code 128 From Here. I didn't directly use the code on this page, but I translated it into the language used by genexus, maybe there was some error in this conversion?
By doing a test, the string "1401" is converted into "ÒQPLÓ" but when I go to print the string setting the code128 font, it is badly formatted, in particular the initial and final characters remain untranslated. I tested this both in word and in a pdf document generated with the genexus program and I get this barcode
(word add the three line after the second O too, I don't know why) I believe that the two accented O's are the characters set by the procedure with the ASCII codes (210 for example is the first O), perhaps there was a misunderstanding here? What am I doing wrong? Is the procedure incorrect? Is it a character set problem? Or what else? Did I misunderstand those lines and don't they represent ASCII codes?
I tried with a barcode reader and there is no way to read this. If I generate the barcode with an online generator everything works fine

Barcode 128 is an oddity for programming as it is non-conventional encoding in its application. Let's start with the output.
You can check that is correct here https://zxing.org/w/decode?u=https%3A%2F%2Fi.stack.imgur.com%2F8tQm7.png
You can also see to get that font as output we need in PDF binary terms an input of
0110100100001110000000010001001001101010which does not match the pixel output. However 01101001 00001110 00000001 00010010 01101010 as hex is69 0e 01 12 6awhich as ASCII / ANSI =Ò.!2Ó.So the rules of generation are
Ò.!2Ówrite those 5 characters using any of several Code 128 fonts.
It is a lot easier if you use a cut and paste tool that calculates ligatures and Mod 103 check bytes.
Here we see it as text in a PDF where the text is now
6C 11 04 15 6Dsince it gets remapped characters (by the MS PDF generator) which in this case seems to have added +3 to each glyph!Calculations in Excel (see https://en.wikipedia.org/wiki/Code_128#Bar_code_widths)
What is odd is that the concept of using Code128 is compaction yet that method of fonts requires many times the resources compared to pixels
Here even with overheads the 54 bars (I added extra 4 white
ÿbars each end, for guarding) is a total file size of just over 750 bytes, but as a font embedded file it is heading for 4 times bigger e.g. 3,199 bytes for the bars without the normal embedded 1401 text.Note cut and paste above will usually distort the bars due to bitrot(ation).
So it will be cleaner white than this (ensure you save as ANSI NOT UTF-8).
So here is how the binary pattern looks as binary on off values, top is the odds and even pairing then shown using * as whitespace for convenience where the black1 will be nul and the white * will become ÿ