Ubuntu GnuCobol CURRENCY SIGN IS "£" 导致编译错误

Ubuntu GnuCobol CURRENCY SIGN IS "£" causes compile errors

在 Ubuntu 18.10 上使用 GnuCOBOL 2.2.0。 通过 Michael Coughlan 的 'Beginning COBOL for Programmers' 工作。 GnuCOBOL 一直在毫无困难地编译本书的示例,直到第 9 章,当这个程序:

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.

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

~/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

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

正如编译器所说:

PICTURE SYMBOL for CURRENCY must be one character long

所以在源文件中找到的 £ 不是一个字符长 - 我假设你使用了 UTF-8 编码并且 GnuCOBOL 不直接支持任何多字节源编码(你实际上得到只要在任何地方都没有 "size overflow" 就可以了。

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