从Progress / OpenEdge中的字符串中删除所有特殊字符时出现奇怪的结果(Strange results when deleting all special characters from

编程入门 行业动态 更新时间:2024-10-18 16:53:53
从Progress / OpenEdge中的字符串中删除所有特殊字符时出现奇怪的结果(Strange results when deleting all special characters from a string in Progress / OpenEdge)

我有下面的代码片段(正如前面的Stack Overflow回答中所建议的那样...... 删除正在进行的字符串4GL中的所有特殊字符 ),它试图从字符串中删除所有扩展字符,以便我可以将其传输到客户的系统它不接受任何扩展字符。

do v-int = 128到255:

assign v-string = replace(v-string,chr(v-int),"").

结束。

它完美地运行了一个例外(这让我担心可能还有其他一些我没有抓到)。 当它达到255时,它将替换字符串中的所有'y'。

如果我做以下......

display chr(255)= chr(121)。 / * 121是y * /的asc代码

我的结果是真实的。

因此,如果我做以下事情......

显示替换(“这真的很奇怪”,chr(255),“”)。

我得到以下结果:

这很奇怪

我已经确认'y'是受运行以下内容影响的唯一字符:

def var v-string as char init“abcdefghijklmnopqrstuvwxyz”。 def var v-int as int。

do v-int = 128到255:

assign v-string = replace(v-string,chr(v-int),“”)。

结束。

显示v-string。

其结果如下:

abcdefghijklmnopqrstuvwxz

我知道我可以通过从范围中删除255来解决这个问题,但我想了解为什么会发生这种情况。

这是一个角色整理设置问题还是我错过了一些更简单的东西?

谢谢你的帮助!

I have the code snippet below (as suggested in this previous Stack Overflow answer ... Deleting all special characters from a string in progress 4GL) which is attempting to remove all extended characters from a string so that I may transmit it to a customer's system which will not accept any extended characters.

do v-int = 128 to 255:

assign v-string = replace(v-string,chr(v-int),"").

end.

It is working perfectly with one exception (which makes me fear there may be others I have not caught). When it gets to 255, it will replace all 'y's in the string.

If I do the following ...

display chr(255) = chr(121). /* 121 is asc code of y */

I get true as the result.

And therefore, if I do the following ...

display replace("This is really strange",chr(255),"").

I get the following result:

This is reall strange

I have verified that 'y' is the only character affected by running the following:

def var v-string as char init "abcdefghijklmnopqrstuvwxyz". def var v-int as int.

do v-int = 128 to 255:

assign v-string = replace(v-string,chr(v-int),"").

end.

display v-string.

Which results in the following:

abcdefghijklmnopqrstuvwxz

I know I can fix this by removing 255 from the range but I would like to understand why this is happening.

Is this a character collation set issue or am I missing something simpler?

Thanks for any help!

最满意答案

这似乎是一个错误!

当替换字符串中的字符CHR(255)(ÿ)时,REPLACE()函数返回意外的结果。

REPLACE()函数修改目标字符的值,但另外它会更改字符串中出现的任何字符'Y'和'y'。

这种行为似乎只影响角色ÿ。 REPLACE()正确更改了其他字符。

使用默认代码页ISO-8859-1

链接到知识库

This seems to be a bug!

The REPLACE() function returns an unexpected result when replacing character CHR(255) (ÿ) in a String.

The REPLACE() function modifies the value of the target character, but additionally it changes any occurrence of characters 'Y' and 'y' present in the String.

This behavior seems to affect only the character ÿ. Other characters are correctly changed by REPLACE().

Using default codepage ISO-8859-1

Link to knowledgebase

更多推荐

本文发布于:2023-08-04 11:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415264.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   特殊字符   奇怪   Progress   OpenEdge

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!