question

osvbnet avatar image
0 Votes"
osvbnet asked osvbnet commented

Convert String to Encoding?

Hello everyone,
I don't find anything to convert a string containing an encoding name to System.Text.Encoding! ie:

Dim Enc as String = "utf-8"
I'll need System.Text.Encoding.UTF8
Any built-in function for that? Thanks

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered osvbnet commented

For example, try this:

 Dim Enc As String = "utf-8"
    
 Dim encoding As System.Text.Encoding = System.Text.Encoding.GetEncoding(Enc)
    
 ' a verification '
 Dim eq = encoding.Equals(System.Text.Encoding.UTF8)

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks dude :)

0 Votes 0 ·