If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

VBA Excel Macro write file using UTF-8 encoding

I'm creating a macro in excel that processes a spreadsheet and writes the content (text) to a file. I need this file to be encoded as UTF-8. I've tried opening the file as unicode using OpenTextFile(... TristateTrue) and StrConv(.. vbUnicode) but those only convert it to UTF-16. I've searched everywhere online and can't find anything. Is this even possible?

Re: VBA Excel Macro write file using UTF-8 encoding

I know of nothing in Excel VBA that can do that and didn't find a Win32 API function for that either. However, actually UTF-8 isn't really so complicated. You can use StrConv() to first convert to UTF-16 and from there do the conversion to UTF-8 yourself. AFAICT Windows doesn't use any Unicode characters beyond the Basic Multilingual Plane anyway, which allows you to simply take the byte pairs from the UTF-16 encoding for Unicode codepoints, simpifying things a bit more.

Eventually, looks like it's a matter of how much effort you want to take for the UTF-8 output.

HTH

I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.