Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    May 31, 2018 @ 06:54
    Matt Barlow | jacker.io
    0

    How do I display non-English characters eg. the Spanish ñ in Razor views without encoding them?

    This might be an easy thing to fix.

    I have a multi language site, the Spanish version of the site is set up to use the es-Es culture and the language is set as:

    <html class="no-js" lang="es">
    

    However, when any content is added in the CMS that contains special non-English characters, these are encoded when I checked the source:

     Espa&#241;a
    

    There is a client requirement for these not to be encoded, when viewing source, it should be:

    España
    

    I know I can use Html.Raw() to not escape the characters, but this wouldn't work with other html entities like ampersand that need to be encoded.

    Is there some extra configuration I need to do to change this?

  • Stephen 767 posts 2273 karma points c-trib
    Jun 02, 2018 @ 10:27
    Stephen
    1

    Yes, there is some extra configuration + some extra code that you need to build into your project. Doing it on my website because I had the exact same issue. Need to find the code (it's Saturday...) and will post.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 02, 2018 @ 10:27
    Jan Skovgaard
    1

    Hi Matt

    I'm wondering why it is so important for them that the characters are not encoded? I mean when they see the site it's going to show just fine as España isn't it?

    I just checked a couple of danish sites we have done throughout the years where danish characters like æ,ø and å are also getting encoded. So far I have not heard that it should be a bad thing? In terms of indexing the site in search engines this should not matter either.

    /Jan

  • Stephen 767 posts 2273 karma points c-trib
    Jun 02, 2018 @ 10:28
    Stephen
    1

    Jan: because the page looks ugly when you look at the source + every single char such as 'é' turns into 'Ӓ' ie 7 chars - I know bandwidth is cheap, but stil.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 02, 2018 @ 11:08
    Jan Skovgaard
    1

    Aaah yes, I never thought of it in that context. But it makes sense #h5yr :-)

    /Jan

  • Stephen 767 posts 2273 karma points c-trib
    Jun 02, 2018 @ 10:48
  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    Jun 04, 2018 @ 10:42
    Matt Barlow | jacker.io
    0

    Stephen, that is awesome, that is a great article and is exactly what I need. H5YR

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies