Search code examples
ubuntucobolgnucobol

Ubuntu GnuCOBOL program DISPLAYs '�' character instead of '£' in edited picture


Unfortunately there is a Part 2 to my earlier question.

That link shows a simple COBOL program moving a value to an edited picture that should precede the value with a '£'.

As per the answer to the earlier question, it's necessary to explicitly set the encoding in the source file to ISO-8859-15 for the program to successfully compile.

Expected output according to the book in front of me:

Edit1 = £12,345.95

Output from running the program:

Edit1 = �12,345.95

I have tried a few of the other western encoding options available in Geany. Some of them also compile, but have the same DISPLAY problem, which seems to be an encoding-related problem.

Does anyone know a way to get the program to work as intended on Ubuntu?


Solution

  • This isn't any kind of OpenCOBOL bug - it's a problem linked to advice I was given in my linked question.

    1. COBOL source files should be encoded ISO-8859-15.
    2. Ubuntu defaults to UTF-8. This means just asking to run the program is asking for its output to be displayed in UTF-8, which does not recognise the ISO-8859-15 pound sign.

    One solution is to explicitly ask the Ubuntu session to use ISO-8859-15:

    $ luit -encoding ISO-8859-15 ./Listing9-2
    Edit1 = £12,345.95