---
title: "HTML på trots server.htmlencode"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/13511-html-på-trots-server-htmlencode"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "MoonCow"
published: "2002-01-02T21:52:00.000Z"
updated: "2002-01-03T07:19:00.000Z"
replies: 2
views: 166
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/13511-html-på-trots-server-htmlencode"
---

# HTML på trots server.htmlencode

## #1 — MoonCow, 2002-01-02T21:52Z

Hej! Detta är inte bra... html går att använda trots att jag trodde jag "server.htmlencode"-at bort det..
min kod ser ut så här:

```
<%

textish = RecSet("mess")
   
'Text including codes to be converted
strText = textish

'HTMLencode to get rid of tags
strText = [b]Server.HTMLEncode(strText)[/b]
                   

strText = Replace(textish, ":)", "<img src='smiley.gif'>")
textish = Replace(textish, ":-)", "<img src='smiley.gif'>")
textish = Replace(textish, "=)", "<img src='smiley.gif'>")
textish = Replace(textish, ";)", "<img src='skamta.gif'>")
textish = Replace(textish, ";-)", "<img src='skamta.gif'>")
textish = Replace(textish, ":D", "<img src='stortsmajl.gif'>")
textish = Replace(textish, ":=D", "<img src='stortsmajl.gif'>")
textish = Replace(textish, ":-D", "<img src='stortsmajl.gif'>")
textish = Replace(textish, ":(", "<img src='sad.gif'>")
textish = Replace(textish, "=(", "<img src='sad.gif'>")
textish = Replace(textish, ":-(", "<img src='sad.gif'>")
textish = Replace(textish, ":p", "<img src='tongue.gif'>")
textish = Replace(textish, ":-p", "<img src='tongue.gif'>")
textish = Replace(textish, ":P", "<img src='tongue.gif'>")
textish = Replace(textish, "=P", "<img src='tongue.gif'>")

textish = Replace(textish, ":&#0124;", "<img src='duh.gif'>")
textish = Replace(textish, ":-&#0124;", "<img src='duh.gif'>")

textish = Replace(textish, ":O", "<img src='wow.gif'>")
textish = Replace(textish, ":-O", "<img src='wow.gif'>")

textish = Replace(textish, ">(", "<img src='hmm.gif'>")
textish = Replace(textish, ":???:", "<img src='ehh.gif'>")

textish = Replace(textish, ":rolleyes:", "<img src='rolleyes.gif'>")
textish = Replace(textish, ":julklapp:", "<img src='julklapp.gif'>")

textish = Replace(textish, vbcrlf, "<br>")

strText = textish

'Creates new regexp
Set objRegExp = New regexp

'Do more than once
objRegExp.Global = true

'Ignore whether upper or lowercase
objRegExp.IgnoreCase = true

'Replace colors

'Pattern to look for
objRegExp.Pattern = "\[(blue)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#003399"">")

'Pattern to look for
objRegExp.Pattern = "\[(red)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#CC0000"">")

'Pattern to look for
objRegExp.Pattern = "\<(b)\>"
'Execute the replacement
strText = objRegExp.Replace(strText,"<b>")

'Pattern to look for
objRegExp.Pattern = "\<(/b)\>"
'Execute the replacement
strText = objRegExp.Replace(strText,"</b>")

'Pattern to look for
objRegExp.Pattern = "\[(white)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#ffffff"">")

'Pattern to look for
objRegExp.Pattern = "\[(yellow)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#F8E187"">")

'Pattern to look for
objRegExp.Pattern = "\[(green)\]"
'Execute the replacement
strText = objRegExp.Replace(strText,"<font color=""#339933"">")

'Replace all ending tags with </font>
objRegExp.Pattern = "(\[\/blue\]&#0124;\[\/red\]&#0124;\[\/green\]&#0124;\[\/white\]&#0124;\[\/yellow\]&#0124;\[\/color\])"
strText = objRegExp.Replace(strText,"</font>")

response.write strText
%>
```

och trots detta (det felstilade) så fungerar html utmärkt och folk kan härja som dom vill :(.. Snälla hjälp mig! 
mvh /Max

Permalänk: https://www.webforum.nu/p/13511

## #2 — Erik Juhlin, 2002-01-02T22:39Z

Du använder ju inte strText sen utan går tillbaka till textish igen.

Permalänk: https://www.webforum.nu/p/302437

## #3 — MoonCow, 2002-01-03T07:19Z

hmm.. jag har sirrat mig blind på det men efter ha skippat dummheterna med att hoppa mellan textish och strText så fick jag det att funka.. tack...

mvh /Max

Permalänk: https://www.webforum.nu/p/302438

---

Tråden på webben: https://www.webforum.nu/amne/asp/13511-html-på-trots-server-htmlencode
