Dhilip89 Posted August 10, 2007 Share Posted August 10, 2007 (edited) Hello, I just made an UDF for Encoding/Decoding the string and HTML Entity Number. HTML.au3: expandcollapse popup#include-once #include <Array.au3> Dim $Entity[65536] $Entity[34] = "quot" $Entity[38] = "amp" $Entity[39] = "apos" $Entity[60] = "lt" $Entity[62] = "gt" $Entity[160] = "nbsp" $Entity[161] = "iexcl" $Entity[162] = "cent" $Entity[163] = "pound" $Entity[164] = "curren" $Entity[165] = "yen" $Entity[166] = "brvbar" $Entity[167] = "sect" $Entity[168] = "uml" $Entity[169] = "copy" $Entity[170] = "ordf" $Entity[171] = "laquo" $Entity[172] = "not" $Entity[173] = "shy" $Entity[174] = "reg" $Entity[175] = "macr" $Entity[176] = "deg" $Entity[177] = "plusmn" $Entity[178] = "sup2" $Entity[179] = "sup3" $Entity[180] = "acute" $Entity[181] = "micro" $Entity[182] = "para" $Entity[183] = "middot" $Entity[184] = "cedil" $Entity[185] = "sup1" $Entity[186] = "ordm" $Entity[187] = "raquo" $Entity[188] = "frac14" $Entity[189] = "frac12" $Entity[190] = "frac34" $Entity[191] = "iquest" $Entity[192] = "Agrave" $Entity[193] = "Aacute" $Entity[194] = "Acirc" $Entity[195] = "Atilde" $Entity[196] = "Auml" $Entity[197] = "Aring" $Entity[198] = "AElig" $Entity[199] = "Ccedil" $Entity[200] = "Egrave" $Entity[201] = "Eacute" $Entity[202] = "Ecirc" $Entity[203] = "Euml" $Entity[204] = "Igrave" $Entity[205] = "Iacute" $Entity[206] = "Icirc" $Entity[207] = "Iuml" $Entity[208] = "ETH" $Entity[209] = "Ntilde" $Entity[210] = "Ograve" $Entity[211] = "Oacute" $Entity[212] = "Ocirc" $Entity[213] = "Otilde" $Entity[214] = "Ouml" $Entity[215] = "times" $Entity[216] = "Oslash" $Entity[217] = "Ugrave" $Entity[218] = "Uacute" $Entity[219] = "Ucirc" $Entity[220] = "Uuml" $Entity[221] = "Yacute" $Entity[222] = "THORN" $Entity[223] = "szlig" $Entity[224] = "agrave" $Entity[225] = "aacute" $Entity[226] = "acirc" $Entity[227] = "atilde" $Entity[228] = "auml" $Entity[229] = "aring" $Entity[230] = "aelig" $Entity[231] = "ccedil" $Entity[232] = "egrave" $Entity[233] = "eacute" $Entity[234] = "ecirc" $Entity[235] = "euml" $Entity[236] = "igrave" $Entity[237] = "iacute" $Entity[238] = "icirc" $Entity[239] = "iuml" $Entity[240] = "eth" $Entity[241] = "ntilde" $Entity[242] = "ograve" $Entity[243] = "oacute" $Entity[244] = "ocirc" $Entity[245] = "otilde" $Entity[246] = "ouml" $Entity[247] = "divide" $Entity[248] = "oslash" $Entity[249] = "ugrave" $Entity[250] = "uacute" $Entity[251] = "ucirc" $Entity[252] = "uuml" $Entity[253] = "yacute" $Entity[254] = "thorn" $Entity[255] = "yuml" $Entity[338] = "OElig" $Entity[339] = "oelig" $Entity[352] = "Scaron" $Entity[353] = "scaron" $Entity[376] = "Yuml" $Entity[402] = "fnof" $Entity[710] = "circ" $Entity[732] = "tilde" $Entity[913] = "Alpha" $Entity[914] = "Beta" $Entity[915] = "Gamma" $Entity[916] = "Delta" $Entity[917] = "Epsilon" $Entity[918] = "Zeta" $Entity[919] = "Eta" $Entity[920] = "Theta" $Entity[921] = "Iota" $Entity[922] = "Kappa" $Entity[923] = "Lambda" $Entity[924] = "Mu" $Entity[925] = "Nu" $Entity[926] = "Xi" $Entity[927] = "Omicron" $Entity[928] = "Pi" $Entity[929] = "Rho" $Entity[931] = "Sigma" $Entity[932] = "Tau" $Entity[933] = "Upsilon" $Entity[934] = "Phi" $Entity[935] = "Chi" $Entity[936] = "Psi" $Entity[937] = "Omega" $Entity[945] = "alpha" $Entity[946] = "beta" $Entity[947] = "gamma" $Entity[948] = "delta" $Entity[949] = "epsilon" $Entity[950] = "zeta" $Entity[951] = "eta" $Entity[952] = "theta" $Entity[953] = "iota" $Entity[954] = "kappa" $Entity[955] = "lambda" $Entity[956] = "mu" $Entity[957] = "nu" $Entity[958] = "xi" $Entity[959] = "omicron" $Entity[960] = "pi" $Entity[961] = "rho" $Entity[962] = "sigmaf" $Entity[963] = "sigma" $Entity[964] = "tau" $Entity[965] = "upsilon" $Entity[966] = "phi" $Entity[967] = "chi" $Entity[968] = "psi" $Entity[969] = "omega" $Entity[977] = "thetasym" $Entity[978] = "upsih" $Entity[982] = "piv" $Entity[8194] = "ensp" $Entity[8195] = "emsp" $Entity[8201] = "thinsp" $Entity[8204] = "zwnj" $Entity[8205] = "zwj" $Entity[8206] = "lrm" $Entity[8207] = "rlm" $Entity[8211] = "ndash" $Entity[8212] = "mdash" $Entity[8216] = "lsquo" $Entity[8217] = "rsquo" $Entity[8218] = "sbquo" $Entity[8220] = "ldquo" $Entity[8221] = "rdquo" $Entity[8222] = "bdquo" $Entity[8224] = "dagger" $Entity[8225] = "Dagger" $Entity[8226] = "bull" $Entity[8230] = "hellip" $Entity[8240] = "permil" $Entity[8242] = "prime" $Entity[8243] = "Prime" $Entity[8249] = "lsaquo" $Entity[8250] = "rsaquo" $Entity[8254] = "oline" $Entity[8260] = "frasl" $Entity[8364] = "euro" $Entity[8465] = "image" $Entity[8472] = "weierp" $Entity[8476] = "real" $Entity[8482] = "trade" $Entity[8501] = "alefsym" $Entity[8592] = "larr" $Entity[8593] = "uarr" $Entity[8594] = "rarr" $Entity[8595] = "darr" $Entity[8596] = "harr" $Entity[8629] = "crarr" $Entity[8656] = "lArr" $Entity[8657] = "uArr" $Entity[8658] = "rArr" $Entity[8659] = "dArr" $Entity[8660] = "hArr" $Entity[8704] = "forall" $Entity[8706] = "part" $Entity[8707] = "exist" $Entity[8709] = "empty" $Entity[8711] = "nabla" $Entity[8712] = "isin" $Entity[8713] = "notin" $Entity[8715] = "ni" $Entity[8719] = "prod" $Entity[8721] = "sum" $Entity[8722] = "minus" $Entity[8727] = "lowast" $Entity[8730] = "radic" $Entity[8733] = "prop" $Entity[8734] = "infin" $Entity[8736] = "ang" $Entity[8743] = "and" $Entity[8744] = "or" $Entity[8745] = "cap" $Entity[8746] = "cup" $Entity[8747] = "int" $Entity[8756] = "there4" $Entity[8764] = "sim" $Entity[8773] = "cong" $Entity[8776] = "asymp" $Entity[8800] = "ne" $Entity[8801] = "equiv" $Entity[8804] = "le" $Entity[8805] = "ge" $Entity[8834] = "sub" $Entity[8835] = "sup" $Entity[8836] = "nsub" $Entity[8838] = "sube" $Entity[8839] = "supe" $Entity[8853] = "oplus" $Entity[8855] = "otimes" $Entity[8869] = "perp" $Entity[8901] = "sdot" $Entity[8968] = "lceil" $Entity[8969] = "rceil" $Entity[8970] = "lfloor" $Entity[8971] = "rfloor" $Entity[9001] = "lang" $Entity[9002] = "rang" $Entity[9674] = "loz" $Entity[9824] = "spades" $Entity[9827] = "clubs" $Entity[9829] = "hearts" $Entity[9830] = "diams" ;=============================================================================== ; ; Function Name: _HTMLEncode() ; Description: Encode the normal string into HTML Entity Number ; Parameter(s): $String - The string you want to encode. ; ; Requirement(s): AutoIt v3.2.4.9 or higher (Unicode) ; Return Value(s): On Success - Returns HTML Entity Number ; On Failure - Nothing ; ; Author(s): Dhilip89 ; ;=============================================================================== Func _HTMLEncode($Str) $StrLen = StringLen($Str) Local $Encoded If $StrLen = 0 Then Return '' For $i = 1 To $StrLen $StrChar = StringMid($Str, $i, 1) $Encoded &= '&#' & AscW($StrChar) & ';' Next Return $Encoded EndFunc ;==>_HTMLEncode ;=============================================================================== ; ; Function Name: _HTMLDecode() ; Description: Decode the HTML Entity Number into normal string ; Parameter(s): $HTMLEntityNum - The HTML Entity Number you want to decode. ; ; Requirement(s): AutoIt v3.2.4.9 or higher (Unicode) ; Return Value(s): On Success - Returns decoded strings ; On Failure - Nothing ; ; Author(s): Dhilip89 ; ;=============================================================================== Func _HTMLDecode($Str) Local $Decoded If $Str = '' Then Return '' $X1 = StringRegExp($Str, '&#x(.*?);', 3) $X2 = StringRegExp($Str, '&#(.*?);', 3) $X3 = StringRegExp($Str, '&(.*?);', 3) For $i = 0 To UBound($X1) - 1 Step 1 $Str = StringReplace($Str, '&#x' & $X1[$i] & ';', ChrW(Dec($X1[$i]))) Next For $i = 0 To UBound($X2) - 1 Step 1 $Str = StringReplace($Str, '&#' & $X2[$i] & ';', ChrW($X2[$i])) Next For $i = 0 To UBound($X3) - 1 Step 1 $Str = StringReplace($Str, '&' & $X3[$i] & ';', ChrW(_ArraySearch($Entity, $X3[$i], 0, 0, 1))) Next $Decoded = $Str Return $Decoded EndFunc ;==>_HTMLDecode Download: HTML.au3 Edited September 22, 2009 by Dhilip89 argumentum, mLipok, Synapsee and 1 other 4 [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote] Link to comment Share on other sites More sharing options...
Dhilip89 Posted August 20, 2007 Author Share Posted August 20, 2007 (edited) Really nobody want reply to this topic ? Edited August 20, 2007 by Dhilip [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote] Link to comment Share on other sites More sharing options...
tito Posted June 8, 2009 Share Posted June 8, 2009 How can I implement this in a loop through a text ? fe , ...decode($fullText) Link to comment Share on other sites More sharing options...
KaFu Posted June 8, 2009 Share Posted June 8, 2009 If the text is not too long, it shouldn't be a problem to push the whole text as one string through the function. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
ptrex Posted June 9, 2009 Share Posted June 9, 2009 @Dhilip89This does more or less the same as my Emailaddressencryptor Regardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
tito Posted June 9, 2009 Share Posted June 9, 2009 If the text is not too long, it shouldn't be a problem to push the whole text as one string through the function.And if the text has multiple encoded characters? Link to comment Share on other sites More sharing options...
WideBoyDixon Posted June 9, 2009 Share Posted June 9, 2009 I'd be more interested in something that handles named entities like ” for example. WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Armand Posted September 22, 2009 Share Posted September 22, 2009 Well... that's pretty lame but it gets the job done... fixed my issues with them entities. #include "__HTMLSpecials.au3" : _____________________________ : expandcollapse popupDim $HTML_SpecialChars[101][2] $HTML_SpecialChars[0][0] = '&' $HTML_SpecialChars[0][1] = 38 $HTML_SpecialChars[1][0] = ' ' $HTML_SpecialChars[1][1] = 160 $HTML_SpecialChars[2][0] = '¡' $HTML_SpecialChars[2][1] = 161 $HTML_SpecialChars[3][0] = '¢' $HTML_SpecialChars[3][1] = 162 $HTML_SpecialChars[4][0] = '£' $HTML_SpecialChars[4][1] = 163 $HTML_SpecialChars[5][0] = '¤' $HTML_SpecialChars[5][1] = 164 $HTML_SpecialChars[6][0] = '¥' $HTML_SpecialChars[6][1] = 165 $HTML_SpecialChars[7][0] = '¦' $HTML_SpecialChars[7][1] = 166 $HTML_SpecialChars[8][0] = '§' $HTML_SpecialChars[8][1] = 167 $HTML_SpecialChars[9][0] = '¨' $HTML_SpecialChars[9][1] = 168 $HTML_SpecialChars[10][0] = '©' $HTML_SpecialChars[10][1] = 169 $HTML_SpecialChars[11][0] = 'ª' $HTML_SpecialChars[11][1] = 170 $HTML_SpecialChars[12][0] = '«' $HTML_SpecialChars[12][1] = 171 $HTML_SpecialChars[13][0] = '¬' $HTML_SpecialChars[13][1] = 172 $HTML_SpecialChars[14][0] = '­' $HTML_SpecialChars[14][1] = 173 $HTML_SpecialChars[15][0] = '®' $HTML_SpecialChars[15][1] = 174 $HTML_SpecialChars[16][0] = '¯' $HTML_SpecialChars[16][1] = 175 $HTML_SpecialChars[17][0] = '°' $HTML_SpecialChars[17][1] = 176 $HTML_SpecialChars[18][0] = '±' $HTML_SpecialChars[18][1] = 177 $HTML_SpecialChars[19][0] = '²' $HTML_SpecialChars[19][1] = 178 $HTML_SpecialChars[20][0] = '³' $HTML_SpecialChars[20][1] = 179 $HTML_SpecialChars[21][0] = '´' $HTML_SpecialChars[21][1] = 180 $HTML_SpecialChars[22][0] = 'µ' $HTML_SpecialChars[22][1] = 181 $HTML_SpecialChars[23][0] = '¶' $HTML_SpecialChars[23][1] = 182 $HTML_SpecialChars[24][0] = '·' $HTML_SpecialChars[24][1] = 183 $HTML_SpecialChars[25][0] = '¸' $HTML_SpecialChars[25][1] = 184 $HTML_SpecialChars[26][0] = '¹' $HTML_SpecialChars[26][1] = 185 $HTML_SpecialChars[27][0] = 'º' $HTML_SpecialChars[27][1] = 186 $HTML_SpecialChars[28][0] = '»' $HTML_SpecialChars[28][1] = 187 $HTML_SpecialChars[29][0] = '¼' $HTML_SpecialChars[29][1] = 188 $HTML_SpecialChars[30][0] = '½' $HTML_SpecialChars[30][1] = 189 $HTML_SpecialChars[31][0] = '¾' $HTML_SpecialChars[31][1] = 190 $HTML_SpecialChars[32][0] = '¿' $HTML_SpecialChars[32][1] = 191 $HTML_SpecialChars[33][0] = 'À' $HTML_SpecialChars[33][1] = 192 $HTML_SpecialChars[34][0] = 'Á' $HTML_SpecialChars[34][1] = 193 $HTML_SpecialChars[35][0] = 'Â' $HTML_SpecialChars[35][1] = 194 $HTML_SpecialChars[36][0] = 'Ã' $HTML_SpecialChars[36][1] = 195 $HTML_SpecialChars[37][0] = 'Ä' $HTML_SpecialChars[37][1] = 196 $HTML_SpecialChars[38][0] = 'Å' $HTML_SpecialChars[38][1] = 197 $HTML_SpecialChars[39][0] = 'Æ' $HTML_SpecialChars[39][1] = 198 $HTML_SpecialChars[40][0] = 'Ç' $HTML_SpecialChars[40][1] = 199 $HTML_SpecialChars[41][0] = 'È' $HTML_SpecialChars[41][1] = 200 $HTML_SpecialChars[42][0] = 'É' $HTML_SpecialChars[42][1] = 201 $HTML_SpecialChars[43][0] = 'Ê' $HTML_SpecialChars[43][1] = 202 $HTML_SpecialChars[44][0] = 'Ë' $HTML_SpecialChars[44][1] = 203 $HTML_SpecialChars[45][0] = 'Ì' $HTML_SpecialChars[45][1] = 204 $HTML_SpecialChars[46][0] = 'Í' $HTML_SpecialChars[46][1] = 205 $HTML_SpecialChars[47][0] = 'Î' $HTML_SpecialChars[47][1] = 206 $HTML_SpecialChars[48][0] = 'Ï' $HTML_SpecialChars[48][1] = 207 $HTML_SpecialChars[49][0] = 'Ð' $HTML_SpecialChars[49][1] = 208 $HTML_SpecialChars[50][0] = 'Ñ' $HTML_SpecialChars[50][1] = 209 $HTML_SpecialChars[51][0] = 'Ò' $HTML_SpecialChars[51][1] = 210 $HTML_SpecialChars[52][0] = 'Ó' $HTML_SpecialChars[52][1] = 211 $HTML_SpecialChars[53][0] = 'Ô' $HTML_SpecialChars[53][1] = 212 $HTML_SpecialChars[54][0] = 'Õ' $HTML_SpecialChars[54][1] = 213 $HTML_SpecialChars[55][0] = 'Ö' $HTML_SpecialChars[55][1] = 214 $HTML_SpecialChars[56][0] = '×' $HTML_SpecialChars[56][1] = 215 $HTML_SpecialChars[57][0] = 'Ø' $HTML_SpecialChars[57][1] = 216 $HTML_SpecialChars[58][0] = 'Ù' $HTML_SpecialChars[58][1] = 217 $HTML_SpecialChars[59][0] = 'Ú' $HTML_SpecialChars[59][1] = 218 $HTML_SpecialChars[60][0] = 'Û' $HTML_SpecialChars[60][1] = 219 $HTML_SpecialChars[61][0] = 'Ü' $HTML_SpecialChars[61][1] = 220 $HTML_SpecialChars[62][0] = 'Ý' $HTML_SpecialChars[62][1] = 221 $HTML_SpecialChars[63][0] = 'Þ' $HTML_SpecialChars[63][1] = 222 $HTML_SpecialChars[64][0] = 'ß' $HTML_SpecialChars[64][1] = 223 $HTML_SpecialChars[65][0] = 'à' $HTML_SpecialChars[65][1] = 224 $HTML_SpecialChars[66][0] = 'á' $HTML_SpecialChars[66][1] = 225 $HTML_SpecialChars[67][0] = 'â' $HTML_SpecialChars[67][1] = 226 $HTML_SpecialChars[68][0] = 'ã' $HTML_SpecialChars[68][1] = 227 $HTML_SpecialChars[69][0] = 'ä' $HTML_SpecialChars[69][1] = 228 $HTML_SpecialChars[70][0] = 'å' $HTML_SpecialChars[70][1] = 229 $HTML_SpecialChars[71][0] = 'æ' $HTML_SpecialChars[71][1] = 230 $HTML_SpecialChars[72][0] = 'ç' $HTML_SpecialChars[72][1] = 231 $HTML_SpecialChars[73][0] = 'è' $HTML_SpecialChars[73][1] = 232 $HTML_SpecialChars[74][0] = 'é' $HTML_SpecialChars[74][1] = 233 $HTML_SpecialChars[75][0] = 'ê' $HTML_SpecialChars[75][1] = 234 $HTML_SpecialChars[76][0] = 'ë' $HTML_SpecialChars[76][1] = 235 $HTML_SpecialChars[77][0] = 'ì' $HTML_SpecialChars[77][1] = 236 $HTML_SpecialChars[78][0] = 'í' $HTML_SpecialChars[78][1] = 237 $HTML_SpecialChars[79][0] = 'î' $HTML_SpecialChars[79][1] = 238 $HTML_SpecialChars[80][0] = 'ï' $HTML_SpecialChars[80][1] = 239 $HTML_SpecialChars[81][0] = 'ð' $HTML_SpecialChars[81][1] = 240 $HTML_SpecialChars[82][0] = 'ñ' $HTML_SpecialChars[82][1] = 241 $HTML_SpecialChars[83][0] = 'ò' $HTML_SpecialChars[83][1] = 242 $HTML_SpecialChars[84][0] = 'ó' $HTML_SpecialChars[84][1] = 243 $HTML_SpecialChars[85][0] = 'ô' $HTML_SpecialChars[85][1] = 244 $HTML_SpecialChars[86][0] = 'õ' $HTML_SpecialChars[86][1] = 245 $HTML_SpecialChars[87][0] = 'ö' $HTML_SpecialChars[87][1] = 246 $HTML_SpecialChars[88][0] = '÷' $HTML_SpecialChars[88][1] = 247 $HTML_SpecialChars[89][0] = 'ø' $HTML_SpecialChars[89][1] = 248 $HTML_SpecialChars[90][0] = 'ù' $HTML_SpecialChars[90][1] = 249 $HTML_SpecialChars[91][0] = 'ú' $HTML_SpecialChars[91][1] = 250 $HTML_SpecialChars[92][0] = 'û' $HTML_SpecialChars[92][1] = 251 $HTML_SpecialChars[93][0] = 'ü' $HTML_SpecialChars[93][1] = 252 $HTML_SpecialChars[94][0] = 'ý' $HTML_SpecialChars[94][1] = 253 $HTML_SpecialChars[95][0] = 'þ' $HTML_SpecialChars[95][1] = 254 $HTML_SpecialChars[96][0] = 'ÿ' $HTML_SpecialChars[96][1] = 255 $HTML_SpecialChars[97][0] = '"' $HTML_SpecialChars[97][1] = 34 $HTML_SpecialChars[98][0] = ''' $HTML_SpecialChars[98][1] = 39 $HTML_SpecialChars[99][0] = '<' $HTML_SpecialChars[99][1] = 60 $HTML_SpecialChars[100][0] = '>' $HTML_SpecialChars[100][1] = 62 _HTMLEntityNumDecode() : _______________________: expandcollapse popup;=============================================================================== ; ; Function Name: _HTMLEntityNumDecode() ; Description: Decode the HTML Entities from a text into normal string. ; Parameter(s): $Text - Whatever text you want to decode. ; ; Requirement(s): AutoIt v3.2.4.9 or higher (Unicode) ; Return Value(s): On Success - Returns decoded text ; On Failure - Nothing ; ; Author(s): Dhilip89, Modified by SK ; ;=============================================================================== Func _HTMLEntityNumDecode($Text) ;ConsoleWrite("+ _HTMLEntityNumDecode() Decoding:: "&@CRLF&$Text&@CRLF) $ReformatedStr = "" $StrExp = StringRegExp($Text, "([\s\S]*?)&#(x?\d+);([\s\S]*)", 3) ;Gives you the TEXT [Entity] TEXT If @error = 0 Then While 1 ;First part isn't an entity - just add it... $ReformatedStr &= $StrExp[0] ;Second part must be an entity [if present] If StringLeft($StrExp[1], 1) = "x" Then ;Check for Dec/Hex variations... HEX is with x. $strHex = StringTrimLeft($StrExp[1], 1) $ReformatedStr &= ChrW(Dec($strHex)) Else $ReformatedStr &= ChrW($StrExp[1]) EndIf ;Look for more entities... $Text = $StrExp[2]; $StrExp = StringRegExp($Text, "([\s\S]*?)&#(x?\d+);([\s\S]*)", 3) ;Gives you the TEXT [Entity] TEXT If @error <> 0 Then ExitLoop WEnd EndIf ;If we had an entity to decode, add the left overs! Else -> return the entire text. $ReformatedStr &= $Text $ret = StringRegExp($ReformatedStr, '(&.+;)', 3) If @error = 0 Then ;We have some specials! #include "__HTMLSpecials.au3" For $i = 0 To UBound($ret)-1 $id = _ArraySearch($HTML_SpecialChars, $ret[$i]) If $id <> -1 Then $ReformatedStr = StringReplace($ReformatedStr, $ret[$i], ChrW($HTML_SpecialChars[$id][1])) If @extended = 0 Then ;ConsoleWrite("Can't convert the entity: "&$ret[$i]&@CRLF) Else ;ConsoleWrite("Switched: "&$ret[$i]& " With: "& ChrW($HTML_SpecialChars[$id][1]) & @CRLF) EndIf Else ;ConsoleWrite("Couldn't find the resolution in $HTML_SpecialChars"&@CRLF) EndIf Next Else ;ConsoleWrite("No Special-Entities"&@CRLF) EndIf ;Dump the array $HTML_SpecialChars = "" ;We are done -> send the new string. [Only entities!] ;ConsoleWrite("- _HTMLEntityNumDecode() Returning:: "&@CRLF&$ReformatedStr&@CRLF) Return $ReformatedStr EndFunc ;==>_HTMLEntityNumDecode I'm '#include "__HTMLSpecials.au3"' since maybe we don't have to load that huge array. [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
Dhilip89 Posted September 22, 2009 Author Share Posted September 22, 2009 Update: replaced obsolete script with better script found in my backup. [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote] Link to comment Share on other sites More sharing options...
squadjot Posted July 9, 2012 Share Posted July 9, 2012 Thanks alot Dhilip89! Link to comment Share on other sites More sharing options...
l4tran Posted May 30, 2019 Share Posted May 30, 2019 I'm trying to convert " Chung Vầng Trăng Đợi " using your UDF but I'm getting "Chung V?ng Trang Ð?i". It suppose to be "Chung Vầng Trăng Đợi " Link to comment Share on other sites More sharing options...
jchd Posted May 31, 2019 Share Posted May 31, 2019 Use this: Local $s = " Chung Vầng Trăng Đợi ", $t $t = Execute("'" & StringRegExpReplace($s, "(&#)(\d+)(;)", "' & ChrW($2) & '") & "'") MsgBox(0, "", $t) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now