Một bộ giải mã exausted hơn epanding C. Ross phản ứng
Function HTMLDecode(sText)
Dim regEx
Dim matches
Dim match
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, " ", Chr(32))
sText = Replace(sText, "¡", Chr(161))
sText = Replace(sText, "£", Chr(163))
sText = Replace(sText, "¥", Chr(165))
sText = Replace(sText, "©", Chr(168))
sText = Replace(sText, "«", Chr(171))
sText = Replace(sText, "»", Chr(187))
sText = Replace(sText, "¿", Chr(191))
sText = Replace(sText, "À", Chr(192))
sText = Replace(sText, "Á", Chr(193))
sText = Replace(sText, "Â", Chr(194))
sText = Replace(sText, "Ã", Chr(195))
sText = Replace(sText, "Ä", Chr(196))
sText = Replace(sText, "Å", Chr(197))
sText = Replace(sText, "Æ", Chr(198))
sText = Replace(sText, "Ç", Chr(199))
sText = Replace(sText, "È", Chr(200))
sText = Replace(sText, "É", Chr(201))
sText = Replace(sText, "Ê", Chr(202))
sText = Replace(sText, "Ë", Chr(203))
sText = Replace(sText, "Ì", Chr(204))
sText = Replace(sText, "Í", Chr(205))
sText = Replace(sText, "Î", Chr(206))
sText = Replace(sText, "Ï", Chr(207))
sText = Replace(sText, "Ñ", Chr(209))
sText = Replace(sText, "Ò", Chr(210))
sText = Replace(sText, "Ó", Chr(211))
sText = Replace(sText, "Ô", Chr(212))
sText = Replace(sText, "Õ", Chr(213))
sText = Replace(sText, "Ö", Chr(214))
sText = Replace(sText, "×", Chr(215))
sText = Replace(sText, "Ø", Chr(216))
sText = Replace(sText, "Ù", Chr(217))
sText = Replace(sText, "Ú", Chr(218))
sText = Replace(sText, "Û", Chr(219))
sText = Replace(sText, "Ü", Chr(220))
sText = Replace(sText, "Ý", Chr(221))
sText = Replace(sText, "Þ", Chr(222))
sText = Replace(sText, "ß", Chr(223))
sText = Replace(sText, "à", Chr(224))
sText = Replace(sText, "á", Chr(225))
sText = Replace(sText, "â", Chr(226))
sText = Replace(sText, "ã", Chr(227))
sText = Replace(sText, "ä", Chr(228))
sText = Replace(sText, "å", Chr(229))
sText = Replace(sText, "æ", Chr(230))
sText = Replace(sText, "ç", Chr(231))
sText = Replace(sText, "è", Chr(232))
sText = Replace(sText, "é", Chr(233))
sText = Replace(sText, "ê", Chr(234))
sText = Replace(sText, "ë", Chr(235))
sText = Replace(sText, "ì", Chr(236))
sText = Replace(sText, "í", Chr(237))
sText = Replace(sText, "î", Chr(238))
sText = Replace(sText, "ï", Chr(239))
sText = Replace(sText, "ð", Chr(240))
sText = Replace(sText, "ñ", Chr(241))
sText = Replace(sText, "ò", Chr(242))
sText = Replace(sText, "ó", Chr(243))
sText = Replace(sText, "ô", Chr(244))
sText = Replace(sText, "õ", Chr(245))
sText = Replace(sText, "ö", Chr(246))
sText = Replace(sText, "÷", Chr(247))
sText = Replace(sText, "ø", Chr(248))
sText = Replace(sText, "ù", Chr(249))
sText = Replace(sText, "ú", Chr(250))
sText = Replace(sText, "û", Chr(251))
sText = Replace(sText, "ü", Chr(252))
sText = Replace(sText, "ý", Chr(253))
sText = Replace(sText, "þ", Chr(254))
sText = Replace(sText, "ÿ", Chr(255))
Set regEx= New RegExp
With regEx
.Pattern = "&#(\d+);" 'Match html unicode escapes
.Global = True
End With
Set matches = regEx.Execute(sText)
'Iterate over matches
For Each match in matches
'For each unicode match, replace the whole match, with the ChrW of the digits.
sText = Replace(sText, match.Value, ChrW(match.SubMatches(0)))
Next
HTMLDecode = sText
End Function
Đã cố gắng mà một, Mã HTML mà tôi đang sử dụng là dành cho chữ Ả Rập nên mã là cái gì đó như ـ mà rõ ràng là ISN' t được bao phủ bởi từ 1 đến 255. –
@Scrooby và 'Chr' không hỗ trợ mọi thứ trong phạm vi đó ... một chút tìm kiếm chỉ ra rằng chức năng' ChrW' thực hiện những gì bạn muốn với unicode. –
Cảm ơn chức năng, tôi đang gặp một vài vấn đề với nó. Khi tôi thử và giải mã một trong các chữ cái Ả Rập, ví dụ: ا nó chỉ trả về dấu chấm hỏi. Tôi đoán nó là một cái gì đó để làm với bộ ký tự trang của tôi, mặc dù trang của tôi được thiết lập để ISO-8859-6 như là hình thức tôi đang cố gắng sử dụng giá trị in –