i like to assign html codes to String variable

  Dim code As String
  code= "  <meta http-equiv="Content-Type" content="text/html; charset=windows-1254">  "

i think i am getting this error because of double Quotation marks
"character constant must contain exactly one character."

how can i assign it to a string?

Recommended Answers

All 4 Replies

Imports System.Web
Dim encoded As var = HttpUtility.HtmlEncode(unencoded)

or:

Also, you can use this if you don't want to use the System.Web assembly:

var encoded = System.Security.SecurityElement.Escape(unencoded)

Per this article, the difference between System.Security.SecurityElement.Escape() and System.Web.HttpUtility.HtmlEncode() is that the former also encodes apostrophe (') characters.

If you want to use the format you gave in the OP you just have to convert the embedded double quotes to double double quotes as follows

code= " <meta http-equiv=""Content-Type"" content=""text/html; charset=windows-1254""> "

I may be mistaken on this but you also may be able to replace the embedded quotes with single quotes as in

code= " <meta http-equiv='Content-Type' content='text/html; charset=windows-1254'> "

thanks all off you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.