【发布时间】:2019-03-03 22:07:25
【问题描述】:
在 Ubuntu 18.10 上使用 GnuCOBOL 2.2.0。 通过 Michael Coughlan 的“为程序员开始 COBOL”工作。 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 不支持英镑符号吗?或者,除了按键盘上的“£”之外,是否需要以不同的方式输入?
【问题讨论】:
-
许多 linux 系统上的默认字符编码(字符集)是 UTF-8,它既有单字节字符也有双字节字符。磅符号是 UTF-8 中的多字节字符。 GNU Cobol 只处理单字节字符 ~ 因此
CURRENCY must be one character long消息。使用单字节编码。 注意: COBOL 倾向于基于字节 -
我很好奇你最终做了什么来解决这个问题?你能分享一下发现吗?谢谢。
-
在 Geany 中打开文件后,选择菜单选项:文档 > 设置编码 > 西欧 > 西方 (ISO-8859-15) 然后保存文件,之后问题就停止了。跨度>