Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pound signs (£) disappearing from ASP.NET strings

I'm usually a LAMP developer, but some .NET work has arrived on my plate and I'm a bit stumped.

If I run the following code:

<% poundsign = "£" %>
<% Response.Write poundsign %>
<% Response.Write "£" %>

… nothing is displayed. However, outside of the <% %> tags (ie in the HTML) £ displays correctly.

I have no trouble displaying the usual alphanumerics, it's just the £ sign that is proving problematic. The underlying file is in Windows 1252 encoding, and I need to serve it as such. If I save the file as UTF-8, I get mojibake instead of a £.

Does anybody have any idea what I can do to make this work, or any settings that might be preventing it from working (other than saving the file in a different format)? Thanks in advance.

EDIT: Sorry guys, I should have mentioned earlier, but &pound; won't help. Aside from the fact that my £s aren't appearing on the page, a major part of my problem is that I need to insert strings containing £ into a SQL server database, but if I form a SQL INSERT statement within the ASP, none of the £ signs end up appearing in the database. Inserting £ signs into the database from ASP isn't a problem when I save the .asp files as UTF-8 files, but I need everything to work in Windows 1252 encoding. Thanks again.

like image 537
S M Avatar asked Jul 22 '10 17:07

S M


1 Answers

Use the ASCII code &pound;

It is an HTML entity and needs to be accessed via the code, read more here.

like image 130
Dustin Laine Avatar answered Oct 03 '22 23:10

Dustin Laine