× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2018-06-20 9:57 AM, Craig Richards wrote:
Yes, any literal in the source file will be encoded in the CCSID of the
Source Physical File.


The issue is that although the literal is encoded in the CCSID of the source file, the compiler thinks it has the CCSID of the job.

Starting in 7.2, you can code CCSID(*EXACT) in the H spec, and then the compiler will understand that the literal has the CCSID of the source file. For things like assignments and comparisons, RPG will do any necessary CCSID conversion on the literal.

But just a warning: Implicit CCSID conversion isn't available (yet) for the string built-in functions. So if you add CCSID(*EXACT) to the H spec, then if you say try to code say %SCAN('@':somefield) and "somefield" defaults to having the job CCSID, then you'll get a compiler error.

Without coding CCSID(*EXACT), I think the easiest way to handle literals with variant code points is to define a variable for each literal, and at program-start, assign the %UCS2 value of the literal to the variable.

dcl-s at_sign char(1);

Then add this at the start of the program.
at_sign = %UCS2('@');

The compiler will convert the '@' from the source file CCSID to UCS-2 at compile time, so the saved literal won't be subject to any job CCSID issues.

But be careful not to just code INZ(%UCS2('@')) for the variable. The compiler will convert the '@' to UCS-2 for the literal, and then it will convert it back to the source file CCSID for the INZ. So you have to initialize the field to the UCS-2 literal in an assignment statement.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.