Textbox to utf8

amiroo

Board Regular
Joined
Dec 24, 2013
Messages
122
Office Version
  1. 2019
Platform
  1. Windows
Hi guys

I have a textbox that contain some text in Persian. I need this text as utf-8 unicode string

I have a code but this code export a file,I need save it as a variable

Code:
Sub Save2File(sText, sFile)
    Dim oStream
    Set oStream = CreateObject("ADODB.Stream")
    With oStream
        .Open
        .Charset = "utf-8"
        .writetext sText
        .SaveToFile sFile, 2
    End With
    Set oStream = Nothing
End Sub
 

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,881
I have a textbox that contain some text in Persian. I need this text as utf-8 unicode string

I have a code but this code export a file,I need save it as a variable

Hi amiroo

utf-8 encodes the characters with a variable number of bytes.

I think, therefore, that you should use a byte array to store the code.

Code:
dim b() as byte

It would also help to know what you intend to do with the variable.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,521
Messages
5,596,651
Members
414,083
Latest member
Mrsash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top