Copied to clipboard

Flag this post as spam?

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


  • Kadir 30 posts 80 karma points
    Aug 29, 2014 @ 13:22
    Kadir
    0

    Special Characters Problem Only on Razor

    Hey,

    One of my domains is in Turkish and in HTML source of the webpage all the special characters are replaced with weird numeric entities like:

    <span class="exclusive">Bize &#214;zel</span>
    <h3>%70&#39;e varan &#199;ok &#214;zel Sezon Indirimş</h3>

    when I use dictionary items or template page fields like 
    <umbraco:Item field="vendorTitle" runat="server" /> there are no problems at all.

    Although all of my razor cshtml files are saved in utf-8 format, I have this weird characters in my HTML source.

    Is there a solution for this? I am running Umbraco v6.2.1 with SQL Server

    Thank you in advance

  • Charles Afford 1163 posts 1709 karma points
    Aug 30, 2014 @ 13:45
    Charles Afford
    1

    First i would look up the encoded characters and see what there value are.

    Let us know what you found :)

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Aug 31, 2014 @ 13:54
    Jeavon Leopold
    1

    That's an interesting issue and perhaps one not specific to Umbraco, have you seen this suggestion on Stack Overflow?

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Aug 31, 2014 @ 13:56
    Jeavon Leopold
    1

    Interested to know if that solves it for you, and also I wonder if when editing Razor files in the Umbraco UI changes the encoding and removes the BOM....?

  • Charles Afford 1163 posts 1709 karma points
    Aug 31, 2014 @ 15:28
    Charles Afford
    1

    Yea i had the same thing with another project. I cannot remember the specifics but we had to save the razor files as UTF-8 with an encoding selected

  • Kadir 30 posts 80 karma points
    Sep 09, 2014 @ 09:30
    Kadir
    0

    Hey all,

    sorry for late reply I was in a trip without laptop and didnt have time to check the answers.

    I have this meta tag already in the template file: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    I also checked all the script files with notepad++ and all of them are with BOM.

    My windows 2012 server is in German, could this be the reason of it?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 09, 2014 @ 09:50
    Chriztian Steinmeier
    1

    Hi Kadir,

    Just curious - when you see the rendered result in a browser, everything's fine, right? (i.e., you get the correct turkish characters, like Ö and Ç, I assume?)

    The browser's parser doesn't see (or do) anything different for the entity reference &#199; and the character Ç - they're both exactly the same thing from the parser's perspective.

    I've seen lots of Tidy tools do the automatic conversion when tidying a document, which probably stems from when some popular browsers couldn't handle anything that wasn't either US-ASCII or Window-1259 encoded, so the tools just converted any "dangerous" characters to entity-references for the sake of the users.

    Maybe your editor does a pre-save tidying step when you save the files?

    /Chriztian

  • Kadir 30 posts 80 karma points
    Sep 09, 2014 @ 12:36
    Kadir
    0

    Hey Chriztian,

    Yes in the rendered results, browser displays everything correctly. I have tried notepadd++, sublimetext editor, notepad and umbraco's native editor, but I still get the same results.

    I have discovered another thing though: when I use @item.incentiveDescription I have encoding problems

    but when I use Truncate like: @(Library.Truncate(Library.StripHtml(item.incentiveDescription), 180, true)) there are no problems at encoding.

  • Kadir 30 posts 80 karma points
    Sep 21, 2014 @ 10:17
    Kadir
    0

    I still couldn't find the source of this problem though.

    Only solution is to use @Html.Raw(abc.ToString()). But I don't know how to apply it for datetimes for example for this : @umbraco.library.FormatDateTime(umbraco.library.CurrentDate(), "MMMM") 
    @HTML.Raw doesn't seem to work.

  • ibrahim TUNC 55 posts 133 karma points
    Feb 06, 2016 @ 22:06
    ibrahim TUNC
    0

    Kadir bey problemi çözebildiniz mi? aynı problemi bende yaşıyorum da.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 06, 2016 @ 23:18
    Jan Skovgaard
    0

    Hi Ibrahim

    Could you please write in english? Unfortunately I don't understand turkish and I think a lot of others in here don't understand that either - So please let's keep this forum in english so everyone can understand each other and help each other out :)

    I'm really curious what you have written above and if I maybe can help ;-)

    Cheers, Jan

  • ibrahim TUNC 55 posts 133 karma points
    Feb 07, 2016 @ 15:21
    ibrahim TUNC
    0

    Hi Jan.

    It asks that the problem is in progress Kadir? I have the same problem too. How can I solve this problem? Can you help me?

    Umbraco installation SQL Server Collation of the database is SQLLatin1GeneralCP1CIAS. Umbraco not support TurkishCI_AS.

    I use Umbraco version 7.2.1 assembly: 1.0.5462.37503.

    Best Regard. Thank you.

  • Samira 113 posts 452 karma points
    Feb 08, 2016 @ 11:10
    Samira
    0

    Hi

    try this

    Use Regex to solve this problem

    string one = childNode.GetProperty("aliasname").Value;
    
    string two = Regex.Replace(one, @"<[^>]+>|&nbsp;", "").Trim();
    
    string correcttext = Regex.Replace(two, @"\s{2,}", " ");
    
    string text = correcttext;
    

    hope this help

    Regards

    Samira

  • ibrahim TUNC 55 posts 133 karma points
    Feb 10, 2016 @ 21:19
    ibrahim TUNC
    0

    Looks like this is a "feature" of Razor that it will always HTML encode attributes. See: Razor - @Html.Raw() still encoding & in meta tag attributes.

    So to work around this, you can do the following:

    <meta name="description" @Html.Raw("content=\""+ @Umbraco.Field("pageDescription") + "\"") />
    

    It's not pretty, but it works.

    Source URL Address : http://sofc.developer-works.com/article/19875431/Meta+description+with+special+characters+in+Umbraco

    It was tested. The problem is solved.

    Thanks. Best regard.

Please Sign in or register to post replies

Write your reply to:

Draft