110,534
社区成员
发帖
与我相关
我的任务
分享
String HTMLDecode(String html)
{
BufferedStream *bs = new BufferedStream(html.Length * 4);
if (bs == nullptr) return html;
LPCTSTR phtml = html;
int offset = 0, last_offset = 0;
while( (offset = html.IndexOf(T("&#"), last_offset)) != -1)
{
bs->Write(&phtml[last_offset], (offset - last_offset) * sizeof(TCHAR));
offset += 2;
int next_offset = html.IndexOf(T(";"), offset);
WORD word = Int32::TryParse(html.Substring(offset, next_offset - offset));
bs->Write(&word, sizeof(word));
last_offset = next_offset + 1;
}
html = (LPTSTR)bs->GetObjectData();
delete bs;
return html;
}