2

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?

Adam
  • 6,041
  • 36
  • 120
  • 208

2 Answers2

3

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.

Palec
  • 12,743
  • 8
  • 69
  • 138
  • Your javascript suggestion in the browser location bar did the trick for me! :) Thanks! – Adam Dec 05 '13 at 22:21
0

How do you include the resource text in the HTML? Are you assigning the value to a label? Do you write it directly to the page? ASP.NET will auto-html-encode the value for a subset of the controls.

The following list of controls do not HTML encode the value you assign. All other controls will auto encode. If you need to show the value in an auto-encoding control, you need to put the raw unicode value in your Resource file, instead of the HTML-encoded version.

To add your unicode text to the resx file you can use ALT+1+0+0+0+3 on the num-pad to insert the character. Or you can copy paste it directly into the editor from any web page or word document or the character map in Windows.

Or to make <% %> not auto-encode your HTML content, use <%= %>.

Community
  • 1
  • 1
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Ah, the first answer that seems to be in the right direction! I checked your link. The value is assigned to a page element like so: <%@ Page MetaDescription="<%$Resources:metadescription%>" So you say I need to add the raw unicode value in my resource file? I checked here http://www.fileformat.info/info/unicode/char/2713/index.htm but I don't know what a raw unicode value looks like. Is it on here? If so, which one should I use? Thank you! – Adam May 22 '13 at 13:50
  • any ideas? :) I'm totally stuck here. – Adam May 24 '13 at 20:34
  • I had already updated my answer. Either use `<%= %>` and keep the HTML encoded characters in your resource file or use ALT-1,0,0,0,3. – jessehouwing May 25 '13 at 20:03
  • Sorry, didn't see that. I tried adding the charachter via Alt+num-pad codes, but then in the .resx files it inserts "‼". When I insert the character in MS-Word via the same key combination I DO see the checkmark symbol. It seems as if my .resx file does not support the encoding? Is that even possible? – Adam May 26 '13 at 08:10
  • Your ResX file is shown in a font that might not have the same representation as Word. Try to see what it looks like in the browser. – jessehouwing May 26 '13 at 08:54
  • Did you try leaving `✓` in the resx, but using `<%= %>` instead of `<% %>`? – jessehouwing May 26 '13 at 08:56
  • I tried adding both unicode and ✓ in my resx file and view the rendered HTML, but I just get the same characters I see in my resx file. And when I replace <%@ Page MetaDescription="<%$Resources:metadescription%>" with <%@ Page MetaDescription="<%=$Resources:metadescription%>" I just get this in my HTML: – Adam May 26 '13 at 09:40