Search code examples
htmlunicodevisual-studio-2012resource-files

HTML/Unicode character and specifically the checkmark character in .resx files are not rendered correctly in HTML?


I'm trying to get checkmarks in my metadata description. Since my site is multilanguage, I add descriptions as follows

<%@ Page MetaDescription="<%$Resources:metadescription%>

When I add these codes checkmark codes (http://www.fileformat.info/info/unicode/char/2713/index.htm)

&#10003; 

or

&#x2713;

or as someone already suggested:

&#10004;

In my Visual Studio 2012 resource file (default.aspx.resx), they are rendered as the exact code and not as a checkmark as I would expect. How can I render the checkmark to the HTML and not the code?

I added this line to my masterpage:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

When I enter this code directly in the HTML:

&#10004;

so in default.aspx, the checkmark is rendered correctly!

when I replace

<%@ Page MetaDescription="<%$Resources:metadescription%>" 

with

<%@ Page MetaDescription="<%=$Resources:metadescription%>" 

I just get this in my HTML:

<meta name="description" content="&lt;%=$Resources:metadescription%>" />

There seems to be something going wrong with HTML codes in the resource files, but how to fix it?


Solution

  • So you just see

    <meta name="description" content="… &#10004; …" />
    

    in the resulting markup and you would like to see

    <meta name="description" content="… ✔ …" />
    

    instead.

    First, I want to point out, that any user agent should decode the &#10004; entity to when reading the content atribute. See attributes in HTML spec. Therefore what you want is really a cosmetic change with virtually no technical impact.

    If you want to get the latter markup (with ), just include the ✔ in your resource file. You could copy & paste it from

    • the Fileformat.info page where it is rendered under string.toUpperCase() in Java Data section or from
    • the page rendered when you put javascript:'&#10004;' into your browser’s location bar.

    Alternatively you could input it directly using and input method. E.g. on Windows you could type Alt+2,7,1,4 (described on Fileformat.info too). For more practical info on input methods of various operating systems see fsymbols.com.