;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       UtoA() and AtoU() 
;; 
;;ACTION         Converts Unicode to ASCII and ASCII to Unicode 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.0  - 2008/10/05 
;; 
;;HISTORY        1.0  - 2008/10/05 - Initial Release 
;; 
;;SYNTAX         UtoA(string) or AtoU(string [, termflag]) 
;; 
;;PARAMETERS     string - REQUIRED - String  
;;               - An ASCII or Unicode string, as per function used 
;; 
;;               termflag - OPTIONAL - Integer 
;;               - A Boolean value determining if the termination char (0000) 
;;               should be added to the string (default is yes) 
;; 
;;REMARKS        This is not a full ASCII/Unicode translator, but simply "good enough" 
;;               for many common tasks, particularly when used with the OutlookSignature 
;;               function. 
;; 
;;RETURNS        string, in ASCII or Unicode, as per function used 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    W2K, WXP, W2K3, Vista 
;; 
;;EXAMPLES       None 
; 
; convert Unicode strings to ASCII 
Function UtoA($_String)
 
  ; return if string is empty 
  If Not $_String Exit 0 EndIf
 
  Dim $_S, $_I				; temp string, index pointer 
 
  ; get each character pair as hex and convert to ASCII character 
  For $_I = 1 to Len($_String) Step 4
    $_S = $_S + Chr(Val('&' + SubStr($_String, $_I, 2)))
  Next
 
  $UtoA = $_S
  Exit 0
 
EndFunction
 
; Convert ASCII strings to Unicode 
Function AtoU($_String, OPTIONAL $_TermFlag)
 
  Dim $_S, $_I				; temp string, index pointer 
 
  ; get each ASCII character and convert to hex words 
  For $_I = 1 to Len($_String)
    $_S = $_S + Right('00' + DecToHex(Asc(SubStr($_String, $_I, 1))), 2) + '00'
  Next
 
  $_TermFlag = IIf($_TermFlag = '', 1, Val($_TermFlag))
  If $_TermFlag
    $AtoU = LCase($_S) + '0000'
  EndIf
 
  Exit 0  
 
EndFunction