Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FGETS() after reading a file line, is inserting a blank character after each valid character. 2

Status
Not open for further replies.

JoseGala

Programmer
Sep 23, 2024
2
After executing the FGETS(file_handle) command Visual FoxPro 9.0 for reading a TXT file, the line has double its original size since it has a blank inserted after each original character

ORIGINAL LINE in TXT file
Date & Time Range: 1/01/21 0:00 12/31/21 23:59

DELIVERY LINE after FGETS()
D a t e & T i m e R a n g e : 1 / 0 1 / 2 1 0 : 0 0 1 2 / 3 1 / 2 1 2 3 : 5 9

What could be cause?
Thank in advance for your help on this

Jose Gala
 
Jose,

The text file is in UNICODE. If possible, FILETOSTR() the file and STRCONV() afterwards.

If you must use FGETS(), you'll have to deal with the fact that the CR+LF characters marking the end of a line are also in UNICODE, taking four bytes instead of the two bytes that FGETS() expects.
 
After executing the FGETS(file_handle) command Visual FoxPro 9.0 for reading a TXT file, the line has double its original size since it has a blank inserted after each original character

ORIGINAL LINE in TXT file
Date & Time Range: 1/01/21 0:00 12/31/21 23:59

DELIVERY LINE after FGETS()
D a t e & T i m e R a n g e : 1 / 0 1 / 2 1 0 : 0 0 1 2 / 3 1 / 2 1 2 3 : 5 9

What could be cause?
Thank in advance for your help on this

Jose Gala
You could also try the ALINES function. Then process the array.
 
After executing the FGETS(file_handle) command Visual FoxPro 9.0 for reading a TXT file, the line has double its original size since it has a blank inserted after each original character

ORIGINAL LINE in TXT file
Date & Time Range: 1/01/21 0:00 12/31/21 23:59

DELIVERY LINE after FGETS()
D a t e & T i m e R a n g e : 1 / 0 1 / 2 1 0 : 0 0 1 2 / 3 1 / 2 1 2 3 : 5 9

What could be cause?
Thank in advance for your help on this

Jose Gala
If you want us to help you debug your FGETS() code, we will need to see your code. No code = WILD GUESSES, most of which will be WRONG.

Having said that, and having written code using FGETS(), it seems very strange to me that FGETS() is causing your problem. Have you examined your text file with a HEX EDITOR to see exactly what is in your text file?
 
Hello mmerlinn
Thank you for your response.
The cause of the issue was having UTF-16 instead of UTF-8, at least.
Thanks to atlopes (see above), it was possible to solve the issue in a very fast way.
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top