Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Convert windows-1252 to utf-8 VB.NET sample code to convert windows-1252 text to utf-8. ' Convert a windows-1252 text file to utf-8.
Dim cc As New Chilkat.Charset()
cc.UnlockComponent("anything for 30-day trial")
Dim byteData As Byte()
byteData = cc.ReadFile("windows-1252.txt")
cc.FromCharset = "windows-1252"
cc.ToCharset = "utf-8"
Dim utf8Bytes As Byte()
utf8Bytes = cc.ConvertData(byteData)
' Write the utf-8 bytes to a text file.
cc.WriteFile("utf8.txt", utf8Bytes)
' Display the utf8 string.
Dim s As String
s = System.Text.Encoding.UTF8.GetString(utf8Bytes)
MsgBox(s)
' Save any string to a file in various encodings:
cc.WriteStringToFile(s, "iso-8859-1.txt", "iso-8859-1")
cc.WriteStringToFile(s, "utf8_again.txt", "utf-8")
cc.WriteStringToFile(s, "windows1252_again.txt", "windows-1252")
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.