Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XMCU1

XMCU1.m

Go to the documentation of this file.
  1. XMCU1 ;(WASH ISC)/CMW-Encode/Decode String APIs ;04/17/2002 08:30
  1. ;;8.0;MailMan;;Jun 28, 2002
  1. ; Entry points (DBIA 1136):
  1. ; $$ENCODEUP - Convert all "^" to "~U~"
  1. ; $$DECODEUP - Convert all "~U~" to "^"
  1. ; $$STRAN - Convert all control characters to printable ones
  1. ; $$RTRAN - Undo the conversion done by $$STRAN
  1. ;
  1. RTRAN(XXX) ; Extrinsic Function to decode control characters
  1. ;Input=STRING
  1. ;Output=STRING
  1. N XMESC,X,Y,X1,I
  1. S XMESC="~"
  1. Q:XXX'[XMESC
  1. S Y="",X1=XXX
  1. R1 S I=$F(X1,XMESC) I I=0 S X=Y_X1 G SET
  1. S Y=Y_$E(X1,1,I-2)_$C($A($E(X1,I))-64#128),X1=$E(X1,I+1,999) G R1
  1. SET Q X
  1. STRAN(XXX) ; Extrinsic Function to encode control characters
  1. ;Input=STRING
  1. ;Output=STRING
  1. N XMESC,Y,X1,I
  1. S XMESC="~"
  1. S Y="" F I=1:1:$L(XXX) S X1=$E(XXX,I) S Y=Y_$S(X1=XMESC:XMESC_$C(62),X1?1C:XMESC_$C($A(X1)+64#128),1:X1)
  1. Q Y
  1. ENCODEUP(XXX) ; Extrinsic Function to encode "^" into "~U~"
  1. ; Input=STRING
  1. ; Output=STRING
  1. F Q:XXX'[U S XXX=$P(XXX,U)_"~U~"_$P(XXX,U,2,999)
  1. Q XXX
  1. DECODEUP(XXX) ; Extrinsic Function to decode "~U~" to "^"
  1. ; Input=STRING
  1. ; Output=STRING
  1. F Q:XXX'["~U~" S XXX=$P(XXX,"~U~")_"^"_$P(XXX,"~U~",2,999)
  1. Q XXX