/* Convert text files between two codepages, line by line -> Thx Alex Taylor!! */ if RxFuncQuery('SysLoadFuncs') then do call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs end if RxFuncQuery('ULSLoadFuncs') then do call RxFuncAdd 'ULSLoadFuncs', 'RXULS', 'ULSLoadFuncs' call ULSLoadFuncs if (RxFuncQuery('ULSConvertCodepage') <> 0) then do call lineout StdErr,'Fatal error: RxULS functions not loaded' exit 1 end end localCP = SysQueryProcessCodePage() parse arg myArgs myArgs = strip(myArgs) if myArgs = '' then do call lineout StdErr,'REXX Txt Converter Tool v0.1 by '||ULSConvertCodepage("Alfredo Fern ndez DĦaz",850,localCP)||' - Usage:' call lineout StdErr,'' call lineout StdErr,'RxTxtCnv [output [Input codepage no. [Output codepage no.]]]' call lineout StdErr,'' call lineout StdErr,'<> = mandatory parameter, substitute value' call lineout StdErr,'[] = optional parameter' call lineout StdErr,'Defaults: ' call lineout StdErr,' output = stdout' call lineout StdErr,' input CP = 1252' call lineout StdErr,' output CP = active codepage ('||localCP||' here and now)' call lineout StdErr,'' call lineout StdErr,'Remarks: parameters are recognized by order -> stdout can be specified' call lineout StdErr,'as "-" to allow changing default input/output codepage numbers' call lineout StdErr,'' call lineout StdErr,'Usually useful codepage numbers:' call lineout StdErr,'Windows West Europe: 1252' call lineout StdErr,'IBM for West Europe: 850' call lineout StdErr,'UTF-8: 1208' call lineout StdErr,'' exit 1 end if left(myArgs,1) = '"' then parse var myArgs '"' inFile '"' MyArgs else parse var myArgs inFile MyArgs MyArgs = strip(MyArgs) if left(myArgs,1) = '"' then parse var myArgs '"' outFile '"' FromCP ToCP else parse var myArgs outFile FromCP ToCP if (outFile = '') | (outFile = '-') then outFile = stdout if FromCP = '' then FromCP = '1252' if ToCP = '' then ToCP = localCP if FromCP = ToCP then do call lineout StdErr,'Error: input and output CP are the same' exit 1 end do while lines(inFile)> 0 new = linein(inFile) if new <> '' then do new = ULSConvertCodepage(new,FromCP,ToCP) call lineout outFile,new end else call lineout outFile,"" end call lineout inFile call lineout outFile exit 0