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

also set your job to that ccsid


And if you are using a 5250 - the remember to set that to to 37

Also the source file - it using so , has to be set to that ccsid ...

On Thu, Dec 8, 2022 at 12:19 AM Roger Lacroix <roger.lacroix@xxxxxxxxxx>


I'm a newbie programmer on IBM i (OS/400) and I need a little bit of help.

I'm having a weird problem with EBCDIC and square brackets, pretty much
as described here:


Recently, a customer was trying out a program but it was not working. It
took a couple of days to realize that they were running their system on
a different code page. At first, I thought I would add their code page
to the hard-coded list but then I thought that solution was stupid and
started hunting for a proper solution.

I decided that what I needed was a lookup table based on the code page
(CCSID) and the HEX values for the square brackets. The trick was
figuring out how to get the code page from the OS (operating system).
After what felt like a millions searches, I can across the nl_langinfo
subroutine. It is available on AIX, Linux, IBM i and z/OS. If you call
nl_langinfo subroutine with the parameter of CODESET then it will return
the code page (aka code set, CCSID) as a string.

Next, I found 101 EBCDIC code pages and created a lookup table of the
square brackets in sorted order by code page. Finally, I created a
routine to issue the nl_langinfo subroutine and then perform a binary
search of the lookup table and set the correct square brackets for the
program to use.

I found what I thought was a solution by using the nl_langinfo(CODESET)
call as detailed here:


I wrote about the lookup table and routine here:

When I run a test program with the nl_langinfo(CODESET) call on my
system, it returns 37 for the code page/CCSID. When I run the following
commands on my system:


They both return code page/CCSID of 37.

So I gave the test program to the customer. When they run the program
it returns 37 for the code page/CCSID. But when the customer run those
2 "DSPSYSVAL SYSVAL" commands, they return 273 for code page/CCSID. And
yes they are in Europe.

So, my question is to those IBM i experts, what am I doing wrong. Note:
The code that I am using was posted in my blog posting. I don't
understand why it didn't return 273 for code page/CCSID.

Is there a better way from a C program to retrieve the correct code
page/CCSID from the IBM i system?

Help please.

Roger Lacroix
Capitalware Inc.

This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L)
mailing list
To post a message email: C400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/c400-l.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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

This mailing list archive is Copyright 1997-2023 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.