Page 1 of 1

Importing text file

Posted: Thu Aug 14, 2008 10:01 pm
by NateC512
Setup -
Mac OS X 10.5.4
Revolution Studio 2.9.0

Something strange is happening when I open a text file (saved as Windows TXT) and put the text of the file into a field (set to use Courier 12pt). The text gets placed okay, but there is a space in between each letter of each word. Very bizarre behavior.

for example - "word" appears as "w o r d"

If I open the file using a regular text editor or MS Word the file looks fine and there are no spaces between the letters of each word.

Anyone have a clue why this is happening?

TIA

Posted: Thu Aug 14, 2008 11:23 pm
by Mark
Hi NateCS,

Probably, you hav a unicode file. After reading the data, you may need to encode it and handle it as unicode rather than raw text. Try something like this:

Code: Select all

open file myFile for binary read
read from file myFile until EOF
close file myFile
put uniencode(it,"UTF8") into myUnicode
set the unicodeText of fld 1 to myUnicode
Best,

Mark

Thanks Mark

Posted: Fri Aug 15, 2008 3:25 pm
by NateC512
That did help in that it did get rid of some extra characters, but the extra spaces remain. Very strange issue. I have tried different encodings and most of them show the added spaces except the Unicode 5 (Little Endian). However, even with that selected the "put" command still adds the spaces.

Any other thoughts?

Posted: Fri Aug 15, 2008 3:45 pm
by BvG
try "Unicode" (utf-16) instead of UTF8.

That did it.

Posted: Fri Aug 15, 2008 4:41 pm
by NateC512
BvG - your suggestion worked.

Thanks.

Found another cool method

Posted: Tue Aug 26, 2008 9:35 pm
by NateC512
In searching for batch text conversion on the Macintosh I found that you can use the textutil utility, inlcuded in Mac OSX 10.4 or better, for converting text from one format to another.

The terminal string I used, which worked great and was tons quicker, was:

find . -name *.txt -exec textutil -convert txt '{}' \;

Just open Terminal, navigate to the directory where you text files exist, and then run this line of code.

Worked like a champ and I did not have to use the "MyUnicode" trick above.

Hopefully this will help others down the line.

Cheers.

Macs Rule!!!