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