Strange results when removing all special characters from a string in Progress / OpenEdge

I have a code snippet below (as suggested in a previous answer on stack overflow ... Removing all special characters from a 4GL string ) which is trying to remove all extended characters from a string so that I can pass it to a client system that won't accept any extended characters.

do v-int = 128 to 255:

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

end.

It works great with one exception (which makes me afraid that there may be others that I did not catch). When it reaches 255, it will replace all the "y" in the string.

If I do the following ...

display chr (255) = chr (121) ./* 121 - age code y * /

I believe in the result.

And so if I do the following ...

display replace ( " ", chr (255), "").

:

, 'y' , :

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

do v-int = 128 255:

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

.

v-.

:

, , 255 , , .

- ?

!

+4
2

, !

REPLACE() CHR (255) (ÿ) .

REPLACE() , "Y" "y", .

ÿ. REPLACE().

ISO-8859-1

+3

. Knowledge Knowledge:

http://knowledgebase.progress.com/articles/Article/000046181

- CHR(), :

CHR(255, "UTF-8", "1252")

:

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, "UTF-8", "1252"), "").

end.

display v-string.

"y" .

+3

Source: https://habr.com/ru/post/1672841/


All Articles