ibm-s390-linux / s390-tools

Tools for use with the s390 Linux kernel and device drivers
MIT License
62 stars 58 forks source link

Erroneous EBCDIC tables in zipl/boot/ebcdic_conv.c #125

Open huth opened 2 years ago

huth commented 2 years ago

zipl/boot/ebcdic_conv.c contains two tables for converting EBCDIC to ASCII, ebcdic_037 and ebcdic_500. However, if you compare the two tables line by line, you can see that they are exactly the same! So this is either a waste of precious bytes, or one of the tables is just wrong. Comparing the tables with the ones in the Linux kernel (arch/s390/kernel/ebcdic.c), it seems to me like ebcdic_500 is wrong and needs fixing?

mario-held commented 2 years ago

When Wikipedia is correct, the tables should not be exactly the same. In https://en.wikipedia.org/wiki/Code_page_37 is stated: Code page 500, known as "International EBCDIC",[5] "International Latin-1" or "International Number 5",[10] is the other major EBCDIC encoding for the ISO/IEC 8859-1 repertoire. It is used in Belgium, Switzerland and on AS/400 systems in Canada.[5] It is related to code page 37 and has the same repertoire, but differs in seven positions; in particular, it encodes [ and ] at 4Ahex and 5Ahex respectively, which are used for the cent sign (¢) and exclamation point (!) in code page 37. The caret (^) is also encoded at 5Fhex, similarly to code page 37-2 and 1047. The ¢ is encoded at B0hex, the ¬ at BAhex, the ! at 4Fhex and the pipe character (|) at BBhex.[14][15] Code page 500 is in turn related to the German code page 273, which swaps several character pairs in a manner corresponding to the differences between DRV8 and ISO/IEC 8859-1, resulting in placement of the hard brackets at 63hex and FChex.[16] I couldn't find more recent documentation inside IBM than that: https://www.ibm.com/docs/en/SSEQ5Y_13.0.0/com.ibm.pcomm.doc/reference/pdf/hcp_referenceV58.pdf which has code pages 037 and 500 included.

huth commented 2 years ago

Yes, there should definitely be a difference in the tables, you can see it in the Linux kernel sources, too (arch/s390/kernel/ebcdic.c).

See my comment here for a suggestion how to fix it:

https://github.com/ibm-s390-linux/s390-tools/issues/126#issuecomment-975720161