While I agree that you need to identify the ascii value of the characters you have at the end, I do want to note that to remove trailing whitespaces, the syntax is $zstrip(x,">W")

Using that removes trailing whitespaces as you can see in the example below.  Additionally, to add the stripping of "control characters" you would just add the C, so $zstrip(x,">WC")

>set x = "  apple   "
 
>write "/" _ $zstrip(x,">W") _ "/"
/  apple/
>