Copied to clipboard

Flag this post as spam?

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


  • Jonas Eriksson 930 posts 1825 karma points
    Feb 23, 2011 @ 11:33
    Jonas Eriksson
    0

    Encoding of characters?

    I'm having problems to display non-english characters in my Razor scripts. In a property value there's no problem.

    But when I try to add them within my script I need to manually html encode them to get them work:

    <h1>åäö test;</h1>
    @{
      var test = "åäö";
      @test
      }

    Returns

    åäö test;
    åäö

    To make it work at all I need to

    &aring;&auml;&ouml;

    @{
      var s=new HtmlString("&aring;&auml;&ouml;");
      @s
    }

    Html.Encode("ö") does not help me either...

    Any advice?

     

     

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 23, 2011 @ 11:36
    Sebastiaan Janssen
    0

    This is the disable-output-encoding thing for XSLT all over again right? ;-)

    Change it to @Html.Raw(test) and it outputs the raw text, not the Html entities. 

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 23, 2011 @ 11:40
    Jonas Eriksson
    0

    Yeah, something like that :-) - but I do get the document property values right. It's just for the strings I create within the script. No luck with @Html.Raw(test) / @Html.Raw("åäö") either I'm afraid.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 23, 2011 @ 11:44
    Sebastiaan Janssen
    0

    Shoot, there's definitely something wrong with my upgraded version, in a clean install I do get this problem as well! Seems a bug.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 23, 2011 @ 12:10
    Sebastiaan Janssen
    0

    Could it be the culture setting? Maybe try adding a hostname with Swedish language?

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 23, 2011 @ 12:33
    Jonas Eriksson
    0

    Good call, but no luck. Found out it has to do with the scripting editor file encoding http://umbraco.codeplex.com/workitem/30073

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 23, 2011 @ 12:36
    Sebastiaan Janssen
    0

    lol aah! who uses that thing anyway? ;-)

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 23, 2011 @ 12:44
    Jonas Eriksson
    0

    Hehe - I do, but I understood you wasnt, thats what got me to open it in VS in the first place :)

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Feb 27, 2011 @ 16:18
    Niels Hartvig
    1

    Fixed :)

  • Jonas Eriksson 930 posts 1825 karma points
    Mar 02, 2011 @ 00:54
    Jonas Eriksson
    0

    Yes, works fine (RC), great!

  • Niclas Lindqvist 48 posts 127 karma points
    Apr 24, 2013 @ 10:01
    Niclas Lindqvist
    0

    What happened! How is "Fixed" the solution for this? I get the same issue, the characters are nice in Richtext editor output, but when i do åäö in a script it's bargled like these: ö weird stuff! Any ideas?

  • Jonas Eriksson 930 posts 1825 karma points
    Apr 24, 2013 @ 10:24
    Jonas Eriksson
    0

    Do you get the error in current version of Umbraco? 

  • Niclas Lindqvist 48 posts 127 karma points
    Apr 24, 2013 @ 10:28
    Niclas Lindqvist
    0

    Yeah, I'm using 6.0.3

    @{
    string brochureTitle = "Produktbrochyr för ";
    string htmlBrochure = "<p><a href="#">" + brochureTitle + "</a></p>";
    } @Html.Raw(htmlBrochure);

    This renders:

    "Produktbrochyr för"

    Or how can I put åäö in manually handled HTML output, otherwise?

    Thanks!

  • Jonas Eriksson 930 posts 1825 karma points
    Apr 24, 2013 @ 10:33
    Jonas Eriksson
    0

    With Razor you can write HTML as is and just add the variables within it with the help of @, for example:

    @{
    // get the data from somewhere
    var someUrl = "/somelink";
    var someTitle = "some title";

    <p><a href="@someUrl">Produktbroschyr för @someTitle</a></p>

     

  • Jonas Eriksson 930 posts 1825 karma points
    Apr 24, 2013 @ 10:37
    Jonas Eriksson
    0

    I just tried entering åäö chars in template editor and in a new macro script in 6.0.3 in the macro editor, and I do not get those errors.

  • Niclas Lindqvist 48 posts 127 karma points
    Apr 24, 2013 @ 10:41
    Niclas Lindqvist
    0

    I'm not using a macro script, but a Partial, could that be the difference?

  • Jonas Eriksson 930 posts 1825 karma points
    Apr 24, 2013 @ 10:46
    Jonas Eriksson
    0

    I see, if I'm not mistaken the bug was the umbraco code editor saved it badly encoded, can you check the actual saved partial view file, in that case this bug has re-appeared

  • Niclas Lindqvist 48 posts 127 karma points
    Apr 24, 2013 @ 10:50
    Niclas Lindqvist
    0

    Hmm, no the partial looks fine! The string has it's correct "åäö" content when shown in WebMatrix as well.

    I've tried creating and outputting the string in the template calling the partial, and that works great, åäö looks beautiful, but when done inside the partial it gets messed up.

  • Niclas Lindqvist 48 posts 127 karma points
    Apr 24, 2013 @ 10:57
    Niclas Lindqvist
    0

    It looks like you were on to this earlier in this thread:

    http://our.umbraco.org/forum/developers/razor/16034-Razor-@helper-in-Umbraco?p=1

    One of your replies contained this:

    3. HtmlEncoding does not happen automatically, so Swedish characters like åäö wont display correctly. I also tried HtmlEncoding my String, but that didnt work either (I got "?"'s). 

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Apr 25, 2013 @ 13:33
    Sebastiaan Janssen
    1

    We recently fixed this, will be part of 6.0.4 coming up today: http://issues.umbraco.org/issue/U4-2118

     

  • Niclas Lindqvist 48 posts 127 karma points
    Apr 25, 2013 @ 13:37
    Niclas Lindqvist
    0

    Sweet!

Please Sign in or register to post replies

Write your reply to:

Draft