Page 1 of 1

ReadProgramString() to support Unicode

Posted: Mon Sep 02, 2013 12:43 am
by IdeasVacuum
Currently ReadProgramString() does not support Unicode, yet many apps output Unicode.

Propose that ReadProgramString() syntax is enhanced to be similar to ReadString()
ReadProgramString(Program, #PB_UTF8)

For those that need to read output in unicode, the method below works, though it's not satisfactory if you want your app to give the User line-by-line progress:

Code: Select all

iSize.i = (1024 * SizeOf(character))
*Buffer = AllocateMemory(iSize)

iApp = RunProgram(sApp, sArgs, sWorkFolder, #PB_Program_Open | #PB_Program_Hide | #PB_Program_Read)

If iApp
         While ProgramRunning(iApp)
         
                   If AvailableProgramOutput(iApp)
         
                          ReadProgramData(iApp, *Buffer, iSize)
                              ;you can set the PeekS text into a ListView/EditorGadget etc
                              Debug PeekS(*Buffer, iSize, #PB_UTF8)
                               FillMemory(*Buffer, iSize, '0', #PB_Character)
                   EndIf
         Wend

         CloseProgram(iApp)
EndIf

FreeMemory(*Buffer)
Edit: Though on WinXP x86 the above code does not update chunk-by-chunk, it does so on Win7

Nevertheless, it would be far better to add unicode support to ReadProgramString(). In the meantime, the Help should be updated to inform that unicode is not supported.