Open tab separated textfile in UTF-8.

  • Thread starter Thread starter Hans
  • Start date Start date
H

Hans

Is it possible for Excel (any version) to open a tab separated text file
saved in UTF-8 encoding? I have big problems showing swedish characters like
åäö in Excel. If i open the text file in notepad and saves as Unicode (not
sure what Unicode means here but I guess it is UTF-16...) Excel seems to
present characters correct.

Regards
/Hans
 
Hi Hans, in fact I'm not good at UTF things but I know Excel can export
UTF.-8 text as an HTML file.
From the main menu, select Tools > Options > General > Web Options >
Encoding.
In Save this document as: combobox, you can select UTF-8.
After that, select File > SaveAs > Web Page. An html file will be generated
keeping UTF-8.
Why don't you open that saved file via IE then SaveAs *.txt?

Sorry I'm in Japanese environment so I cannot test.
 
Hi Colo!
Why don't you open that saved file via IE then SaveAs *.txt?
Well this is of course possible but then I can stick to what I have and
resave the txt file in notepad to Unicode instead of UTF-8. The strange
thing is that neither word or access have any problems reading the file but
excel has and I cannot (or at least it is hard) to create my file in UTF-16
in the first place since it is created in a asp application (com+ component)
where everything is set up to be utf-8 encoded. I tried to change the
codepage to utf-16 but IIS told me it was not legal to use this codepage. I
still think it is strange that Excel cannot read UTF-8 text document.

Regards
/Hans
 
Hi Hans,
So how does this code works in your environment?
(Please change the path in the following code to the appropriate one.)

'Need reference to Microsoft ActiveX Data Objects x.x Library
Sub TestingUTF()
Dim DataSet(1 To 2) As New ADODB.Stream
With DataSet(1)
.Open
.Charset = "unicode"
.LoadFromFile "c:\Unicode.txt"
End With
With DataSet(2)
.Open
.Charset = "utf-8"
DataSet(1).CopyTo DataSet(2)
.SaveToFile "C:\utf-8.txt"
End With
DataSet(1).Close: DataSet(2).Close
End Sub
 
Hi again Colo!

The export file (tab separated) is cretated from a recordset on the server
(never stored to disc on server side) and transported to the client via
response.write (with appropriate content-headers etc). If a script on the
client should be able to convert the file automatically from utf-8 to
unicode (utf-16) it must (as far as I understand) either user client side
vbscript (IE only) or run inside an activeX component. None of these are
acceptable due to browser support/security issues.

I was hoping it was possible to get Excel to understand a textfile encoded
in UTF-8.

Regards
/Hans
 
Back
Top