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 email@example.com.
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?
As an Amazon Associate we earn from qualifying purchases.