|
On 2018-06-20 9:57 AM, Craig Richards wrote:
Yes, any literal in the source file will be encoded in the CCSID of theThe issue is that although the literal is encoded in the CCSID of the
Source Physical File.
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.
--
Barbara
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.