1. Simone Olianti
  2. PowerBuilder
  3. Thursday, 15 November 2018 12:08 PM UTC

Hello i have a source text file with ansi encoding written using Macintosh (CR) containing a sequence of EOT,EOT NUL characters every 1024 bytes.
I need to read this file and convert it to a string. I tried to open it in stream mode, and used the filereadex to put the content in a blob variable. Anyway when i try to convert the blob to a string i get it truncated before the first NUL character.

li_FileNum = FileOpen(ls_nomefile, streamMode!, Read!, LockWrite!,  Replace!)
eRet = FileEncoding(ls_nomefile)          
li_bytes = FileReadEx(li_filenum, bdata)
ls_string = string(bdata, eRet)

Is there a simple way to remove the NUL characters and get the whole file in a string variable?

Attachments (1)
Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 15 November 2018 14:35 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Simone;

      Strange enough, I just solved this issue with my new daughter in-law's MAC computer. When you create a file on the MAC, the binary content is not compatible with MS-Windows based PC's. What I needed to do was have her use a USB that I formatted using the FAT format. Once the MAC saw the device where the file was being created as Windows FAT format, it wrote the file using MS-Windows binary encoding. From there, I was now able to open and process the file datum via PB.

HTH

Regards ... Chris

Comment
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.