[stackoverflow] [progress Openedge Abl] Strange Results When Deleting All Special...

Status
Not open for further replies.
J

John Pierce

Guest
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!

Continue reading...
 
Status
Not open for further replies.
Top