Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Decode HTML Entities
Visual Basic example program showing how to decode HTML entities. Dim cc As New ChilkatCharset2 cc.UnlockComponent "anything for 30-day trial" ' This file can be downloaded from: ' http://www.chilkatsoft.com/text-samples/html_entities.txt ' The html_entities.txt file contains lines such as: ' pound sign £ £ £ ' cent sign ¢ ¢ ¢ ' pound sign £ £ £ ' currency sign ¤ ¤ ¤ ' yen sign = yuan sign ¥ ¥ ¥ ' Latin small letter ae = Latin small ligature ae æ æ æ ' Latin small letter c with cedilla ç ç ç ' Latin small letter e with grave è è è ' Latin small letter e with acute é é é ' Latin small letter e with circumflex ê ê ê ' Latin small letter e with diaeresis ë ë ë ' Latin small letter i with grave ì ì ì ' Latin small letter i with acute í í í ' Latin small letter i with circumflex î î î ' Latin small letter i with diaeresis ï ï ï ' Latin small letter eth ð ð ð ' First, load the text file into a VB string: Dim textData As Variant textData = cc.ReadFile("html_entities.txt") cc.FromCharset = "iso-8859-1" Text3.Text = cc.ConvertToUnicode(textData) ' Because HTML entities may represent characters in any language, ' the result of the entity decoding is always utf-8. ' Therefore, we first decode and then convert to a VB string (from utf-8) Dim decoded As Variant decoded = cc.HtmlEntityDecode(Text3.Text) cc.FromCharset = "utf-8" Text4.Text = cc.ConvertToUnicode(decoded) ' Alternatively, we can decode the entities directly from file-to-file: cc.ToCharset = "iso-8859-1" cc.HtmlEntityDecodeFile "html_entities.txt", "html_entities_decoded.txt"
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.