Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classic ASP (VBScript) replace special character in a string is acting strange

In classic ASP (VBScript), when I replace the string, a strange character appears.

<%
    myString = "My Ttitle &#174;"
    myString = Replace(myString,"&#174;", "®")
    Response.Write(myString)
%>

If I print this out to HTML, the final result is (Which has a strange A in it):

My Ttitle ® 
like image 822
user1187968 Avatar asked Mar 21 '23 07:03

user1187968


2 Answers

  1. add this at the top of your page <%@ language="vbscript" codepage="65001"%>

  2. open your file in a text editor, (notepad will do) select Save As from the file menu and choose utf-8 rather than ANSI encoding

  3. add in your head section <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> (this isn't actually necessary but it doesn't do any harm)

Further information here

http://www.hanselman.com/blog/InternationalizationAndClassicASP.aspx

like image 160
John Avatar answered Mar 22 '23 21:03

John


Change

myString = Replace(myString,"&#174;", "®")

to

myString = Replace(myString,"&#174;", "&reg;")
like image 25
meda Avatar answered Mar 22 '23 19:03

meda