Importing text files - file type (UTF-16 for instance)


#1

Hi,
I’m using the iFrame and responds_to_parent method to import some text
files (csv files) from various sources. Some of the files of interest
are in UTF-8 or UTF-16 format.

How can my code determine what the file type is of an imported file?
How can I convert a file from UTF-16 to a 7 or 8 bit file (for now at
least, I’m not required to deal with languages that actually need 16
bits.) GMail, for instance, exports UTF-16 files, even if the contents
are all English or other 8 bit languages.

So when I import one, I get alternating ascii chars and diamond with a
question mark in the middle chars (I assume that’s how my Mac displays
an ascii NULL.

I suppose I could snoop the type from the gathered data by looking for
the alternating null chars, but that seems really cheesy.

thanks!

jp