Ubuntu GnuCobol货币符号为“£”;导致编译错误 [英] Ubuntu GnuCobol CURRENCY SIGN IS "£" causes compile errors

查看:167
本文介绍了Ubuntu GnuCobol货币符号为“£”;导致编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Ubuntu 18.10上使用GnuCOBOL 2.2.0。
迈克·科夫兰(Michael Coughlan)撰写的面向程序员的COBOL入门。
GnuCOBOL一直在编写本书的示例而没有麻烦,直到第9章,该程序使用以下程序:

Using GnuCOBOL 2.2.0 on Ubuntu 18.10. Working through 'Beginning COBOL for Programmers' by Michael Coughlan. GnuCOBOL has been compiling the book's examples without trouble up until Chapter 9, when this program:

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.

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

...throws the following errors when attempting to compile:

~/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不支持英镑符号吗?或者,是否需要以不同于仅在键盘上按£的方式输入?

If all the £ characters are replaced by $, the compile succeeds. Could the problem be that GnuCOBOL does not support the British pound sign? Or, does one have to enter it a different way than just pressing '£' on the keyboard?

推荐答案


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

PICTURE SYMBOL for CURRENCY must be one character long

,因此在源文件中找到的£不是字符长-我假设您使用了UTF-8编码,而GnuCOBOL不直接支持任何字符多字节源编码(只要在任何地方都没有大小溢出,您就可以避免使用它。)

so the £ found in the source file is not a character long - I assume you've used UTF-8 encoding and GnuCOBOL doesn't directly supports any multi-byte source encoding (you actually get away with it as long as there is no "size overflow" anywhere).

如果可能的话,我建议将编码更改为< a href = https://en.wikipedia.org/wiki/ISO/IEC_8859-15 rel = noreferrer> ISO-8859-15 是一种单字节编码,其中包含井号

If possible I suggest to change the encoding to ISO-8859-15 which is a single-byte encoding which has the pound sign included.

这篇关于Ubuntu GnuCobol货币符号为“£”;导致编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆