View Single Post
  #1 (permalink)  
Old May 9th, 2005, 03:45 PM
forum1 forum1 is offline
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unicode UTf-8? System.Text.UTF8Encoding from VBA?

I'm writing VBA code embedded in an Excel spreadsheet.

I need to convert strings from Unicode UTF-8 to standard string objects.

If you read the MSDN docs, it looks like the way is the object System.Text.UTF8Encoding. But it SEEMS like there is no way to use it from the VBA world. It seems like it might be Visual Basic.NET only, but not exported to the VBA world. Is that true?!?!?

How the heck do I do this?

I can create VBA code that does createobject("System.Text.UTF8Encoding") which runs fine, but then the object that it creates can't take any messages. :-(

  Dim myconverter
  Set myconverter = CreateObject("System.Text.UTF8Encoding") ' no error

  Dim encodedBytes
 encodedBytes = myconverter.GetBytes("sdsf") ' THIS FAILS - no GetBytes

There is some commercial developer who licenses some DLL to do this from VBA/VBscript, but that seems ridiculous, and wouldn't work in my architecture anyway -- i need it all to be contained within the Excel file.

Any ideas?!?!

Thanks!

Reply With Quote