Ubuntu GnuCobol货币符号为“£”会导致编译错误

Geo*_*mer 5 cobol gnucobol

在Ubuntu 18.10上使用GnuCOBOL 2.2.0。Michael Coughlan撰写的“面向程序员的COBOL入门”一文。直到第9章,GnuCOBOL一直在毫不费力地编译本书的示例,当时该程序:

IDENTIFICATION DIVISION.
PROGRAM-ID. Listing9-2.
AUTHOR. Michael Coughlan.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
    CURRENCY SIGN IS "£".
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Edit1    PIC £££,££9.99.

PROCEDURE DIVISION.
Begin.
    MOVE 12345.95 TO Edit1
    DISPLAY "Edit1 = " Edit1
    STOP RUN.
Run Code Online (Sandbox Code Playgroud)

...在尝试编译时抛出以下错误:

~/Documents/COBOL$ cobc -x -free Listing9-2.cbl
Listing9-2.cbl: 8: error: PICTURE SYMBOL for CURRENCY must be one character long
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: 11: error: invalid PICTURE character '?'
Listing9-2.cbl: in paragraph 'Begin':
Listing9-2.cbl: 15: error: invalid MOVE statement
Run Code Online (Sandbox Code Playgroud)

如果所有的£字符都替换为$,则编译成功。问题可能是GnuCOBOL不支持英镑符号吗?或者,是否需要以不同于仅在键盘上按“£”的方式输入?

Sim*_*sch 6

正如编译器所说:

用于货币的图片符号必须为一个字符长

因此,£在源文件中找到的字符不是长字符-我假设您使用了UTF-8编码,并且GnuCOBOL不直接支持任何多字节源编码(只要没有“大小溢出”)。

如果可能的话,我建议将编码更改为ISO-8859-15,这是一种包含字节符号的单字节编码。