× 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.



Thanks for the info and the warning Barbara.

Very useful and easier than the old solution I linked which basically
defined any literals in hex for CCSID 500 and then used iconv() to
translate them to the Job CCSID at runtime.

best regards,
Craig

On 20 June 2018 at 23:31, Barbara Morris <bmorris@xxxxxxxxxx> wrote:

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.

--
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 thread ...

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.