简体   繁体   中英

String/Regular expression characters '[', ']', '{', '}' replaced by spaces on Mainframe TN3270 (with code page 1047,1147,500,249) in C language

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.

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: 设置终端会话的1047代码页

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. 此屏幕显示适合我的会话的选项。请注意,我选择了2号

显示正确显示的括号。

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM