I have created a function in C language for identifying the integer with some conditions using regex. The regex expression is working fine on UNIX and other platform, but when I used the same piece of code on Mainframe TN3270, characters in string/regular expression like '[', ']', '{', '}' are replaced by spaces during compilation. I tried using '\' before all these characters and , REG_EXTENDED during regcomp, but no change in result.

int VALNUM ()
{                                        
   regex_t s_regex, *ps_regex = &s_regex;
   char pc_regexpInt[ ] = "^[+-]{0,1}[0-9]{1,} *";
   printf("pc_regexpInt value:%s\n",pc_regexpInt);
   regcomp(ps_regex, pc_regexpInt, REG_EXTENDED)
   regexec(ps_regex, pc_buffer, 0, NULL, 0);
   regfree(ps_regex);
}

For me the printf returns:

pc_regexpInt value:^ +-  0,1  0-9  1,  *

And regexec also failed for the pc_buffer value like (+120 or -3.1415).

Note: There is no issue with code compilation, here I have just written a piece of my code. The declaration and all are missing here, that's not an issue.

Anyone please suggest.

2

There are 2 answers

0
Kevin McKenzie On

TN3270 is a protocol for connecting to z/OS and other operating systems. I'm assuming you're using z/OS, here. z/OS, in general, uses EBCDIC, not ASCII, for character encodings. As @Ctx says, different character sets have different mappings, and the TN3270 client needs to be using the appropriate mapping, along with the host system.

So you need to be using a code page with {, }, (, and ) in it. Code page 1047 is often used for this. But you need to make sure that you're using it on both the host system, probably set through ISPF option 0, and in your client, which could be done a variety of different ways. See https://www.askthezoslady.com/tag/setting-tso-code-page/ for more information.

0
Hogstrom On

There are a few factors at play. The code page of the editor in ISPF (if that is what you are using), the terminal setup for the 3270 session in ISPF and the code page for the code your running.

For 3270 I find that using codepage Codepage 1047 works for me. That code page maps the open and close brackets to 0xAD [ and 0xBD ] respectively. There are a variety of other code pages but they are generally mapped for the coding needs of locales that need other characters to Latin-1.

Setting up the code page for the emulator. For example, I use HostOnDemand by selecting the properties on the session and then: Setting 1047 Code page for terminal session

Next you need ISPF setup. This is choosing a terminal type that supports the brackets. In ISPF set your terminal type to 3277A by selection Menu -> Settings. This screen shows the options in place for my session.  Note that I selected number 2

Showing the brackets correctly displayed.

The final piece is the your setup for C and its Locale. Found this reference that should help get you through the last pieces.