classic asp chr() function issue

1.1k Views Asked by At

I was trying to implement RC4 encription in ASP but I found a strange behaviour on chr() function.

but the issue is not related to RC4 script but to something I've not been able to solve.

Not to mention all the test I've done, I could riproduce the issue in a very simple form:

I simply wrote

<%=chr(146)%>

in 2 pages, let say L2.asp and L3.asp

page L2.asp shows ' thus html &rsquo;

page L3.asp shows �

clearly both pages are on the same server (Windows Server 2012 R2) but it seems page L3.asp does not recognize Extended ASCII Table.

I try adding <% Response.Charset="ISO-8859-1"%> on top.. and many other solution but nothing changes..

although the script is very simple (but tested also longer script with rc4 routine), if I copy the content of L2.asp in L3.asp or viceversa, the behaviour of the page remains unchanged, thus, L2.asp contiunes to show ' while L3 shows �, and changing name of the page will not change behaviour.

do have some idea what can create such strange behaviour?

Thanks a lot for any hint

1

There are 1 best solutions below

0
On BEST ANSWER

It's not about Chr function.
� is UTF8-BOM which is optional for UTF-8 files.
First try to save ASP files in UTF-8 without BOM. You can use an advanced editor like Notepad++.
Follow the steps: Open "file.asp" > Encoding > Convert to UTF-8 and then File > Save.

Response.Charset simply appends the name of the character set to the Content-Type response header and does nothing on server-side.
Instead you must specify Response.CodePage = 1252.