Check Half width Katakana character in COBOL

452 Views Asked by At

I'm working on RedHat6 and using COBOL. I wanna check every single digit of variable, if it's half width --> CONTINUE, Else --> DISPLAY ERROR. Basicly I list all half width characters in WHEN Clause of EVALUATE statement. Like this:

PERFORM VARYING WK-IX FROM 1 BY 1 UNTIL WK-IX > WK-LENGTH
    EVALUATE WK-FORMAT-CHK-VALUE(WK-IX:1)
        WHEN 'A'
        WHEN 'B'
        WHEN 'C'
            CONTINUE
        WHEN OTHER
            DISPLAY 'ERROR'
    END-EVALUATE
END-PERFORM.

Everything is OK but when compile I have problem with half width katakana character. It said: "The ending quotation mark of the literal is missing. The characters at the end of Area B are assumed to be a literal" with all line check these character:

ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン

Although I sure there isn't any line of code miss the ending quotation mark. Like this:

WHEN 'ツ'
WHEN 'テ'
WHEN 'ト'

But these character is OK and I don't know why:

ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ

Anyone can help me? Please! Sorry for my bad English!

1

There are 1 best solutions below

2
SaggingRufus On

Because the Katakana character set is considered a multi-byte character set (as mentioned by Bill Woodger), you will need to ensure that the NSYMBOL and DBCS compile options are enabled. After that, you should be able to define the literals like this:

EVALUATE WK-FORMAT-CHK-VALUE(WK-IX:1)    
   WHEN N'ツ'
   WHEN N'テ'
   WHEN N'ト'
      do something
   WHEN OTHER
      do something else
END-EVALUATE

the N will tell the program that this is a national character and as such is multi-byte.

Your input to the evaluate clause will also need to be defined as a PIC N rather than a PIC X. A PIC X field will not recognise double byte characters.