简体   繁体   English

字符串/正则表达式字符'[',']','{','}'用C语言在大型机TN3270(代码页1047,1147,500,249)上替换为空格

[英]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. 我用C语言创建了一个函数,用于使用正则表达式在某些条件下识别整数。 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. regex表达式在UNIX和其他平台上可以正常工作,但是当我在Mainframe TN3270上使用同一段代码时,字符串/正则表达式中的字符,例如[[,']','{','}'被替换为编译期间的空格。 I tried using '\\' before all these characters and , REG_EXTENDED during regcomp, but no change in result. 我在regcomp期间尝试在所有这些字符和REG_EXTENDED之前使用'\\',但结果没有变化。

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: 对我来说,printf返回:

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

And regexec also failed for the pc_buffer value like (+120 or -3.1415). 并且regexec对于pc_buffer值(如+120或-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. ISPF中编辑器的代码页(如果正在使用的话),ISPF中3270会话的终端设置以及正在运行的代码的代码页。

For 3270 I find that using codepage Codepage 1047 works for me. 对于3270,我发现使用代码页Codepage 1047对我有效。 That code page maps the open and close brackets to 0xAD [ and 0xBD ] respectively. 该代码页将左括号和右括号分别映射到0xAD [和0xBD ] 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. 还有许多其他代码页,但通常是将它们映射以满足需要将其他字符转换为Latin-1的语言环境的编码需求。

Setting up the code page for the emulator. 设置仿真器的代码页。 For example, I use HostOnDemand by selecting the properties on the session and then: 例如,我通过选择会话上的属性来使用HostOnDemand,然后: 设置终端会话的1047代码页

Next you need ISPF setup. 接下来,您需要设置ISPF。 This is choosing a terminal type that supports the brackets. 这是选择支持括号的终端类型。 In ISPF set your terminal type to 3277A by selection Menu -> Settings. 在ISPF中,通过选择菜单->设置将终端类型设置为3277A。 此屏幕显示适合我的会话的选项。请注意,我选择了2号

显示正确显示的括号。

The final piece is the your setup for C and its Locale. 最后一部分是您对C及其语言环境的设置。 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. TN3270是用于连接到z / OS和其他操作系统的协议。 I'm assuming you're using z/OS, here. 我假设您在这里使用z / OS。 z/OS, in general, uses EBCDIC, not ASCII, for character encodings. 通常,z / OS使用EBCDIC而非ASCII进行字符编码。 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. 正如@Ctx所说,不同的字符集具有不同的映射,并且TN3270客户端需要与主机系统一起使用适当的映射。

So you need to be using a code page with {, }, (, and ) in it. 因此,您需要使用其中包含{,},(和)的代码页。 Code page 1047 is often used for this. 代码页1047通常用于此目的。 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. 但是,您需要确保可以在主机系统(可能是通过ISPF选项0设置)上以及在客户端中都使用它,可以通过多种不同的方式进行操作。 See https://www.askthezoslady.com/tag/setting-tso-code-page/ for more information. 有关更多信息,请参见https://www.askthezoslady.com/tag/setting-tso-code-page/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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