asp.netasp.net-mvcwebencodingutf

How can I transfer text in Ukrainian to microdata?


I have an incomprehensible problem. I'm making an ASP.NET site and I want to stretch microdata to my site. I have the following microdata for HTML code

@model ListPlatformsVM

@section Microdata {
    <script type="application/ld+json">
        {
            "@@context": "https://schema.org/",
            "@@type": "BreadcrumbList",
            "itemListElement": [
                {
                    "@@type": "ListItem",
                    "position": "1",
                    "name": "@Model.str",
                    "item": "@Url.GetRouteUrl(EReviewerRoute.HomePage)"
                },
                {
                    "@@type": "ListItem",
                    "position": "2",
                    "name": "тестовий текст",
                    "item": "@Url.GetRouteUrl(EReviewerRoute.Platforms)"
                }
            ]
        }
    </script>
}

As you can see, I am passing the @Model.str variable from the model to the microdata. str is of type string (UTF-16). By breakpoints it is clear that the text in str is normal, but I get this result

enter image description here

Instead of my text in Ukrainian, strange characters are displayed &#x442;&#x435;&#x441;&#x442; There are a couple of other things that might help:

  1. If you enter the Ukrainian text not through a variable, then everything is displayed normally
  2. English text is displayed normally anyway

I want to display Ukrainian text using a variable passing it to the html code. Please help me, thanks in advance


Solution

  • Try using HtmlHelper.Raw method:

    Wraps HTML markup in a HtmlString, without HTML-encoding the specified value.

    "name": "@Html.Raw(Model.str)"