Convert UTF-16 Unicode to UTF-8 Unicode?

G

Greg Lovern

If I save an Excel file as "Unicode Text" (xlUnicodeText), I get a tab-
delimited UTF-16 (also known as UTF-7) unicode file.

How can I convert it to UTF-8?


I've been doing the conversion by automating Word from Excel:

Const WORD_TEXT_FORMAT As Long = 2 'FileFormat:=wdFormatText
Const WORD_UTF8_ENCODING As Long = 65001 'Encoding:=65001

ObjWordDoc.SaveAs _
Filename:="save as UTF-8.txt", _
FileFormat:=WORD_TEXT_FORMAT, _
Encoding:=WORD_UTF8_ENCODING


However, now I need to convert from UTF-16 to UTF-8 on computers that
may not have Word installed. Any suggestions?


Thanks,

Greg
 
J

joel

I 've done this type stuff before. It may be a little tricky becaus
the byte order of the 16 bit data may be reversed. I don't understan
how UTF-16=UTF-7. UTF-16 is two byte data without any parity. UTF-7 i
7 bit data which may or may no contain a parity bit. UTF-8 is 8 bi
data with no parity so you can get 256 characters.

I don't understand what tab delimited UTF-16 means. I would need t
see a sample of the data. Tab delimited I've only seen as 7 or 8 bi
data. whatt happens to the data if you open it in NOTEPAD? Notepa
will automatically convert UTF-16 to UTF-8 (it may look a littl
funny).

Usually the UTF-16 problems aresolved opening the data file as binar
in VBA and then writing some code to change the format. I usually ope
two files from VBA (one input binary and one output no binary) if
don't need the final results in a spreadsheet. Otherwise, I open jus
one file as binary input and read the data into excel worksheet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top