1

my problem in this question is with Persian characters : in my app , in browser , my messages and texts are display very well but in back of the Scene is not good , look at image: enter image description here

and back (in browser page source): enter image description here

there are this characters , and main problem is here :

enter image description here

in view.cshtml:

@foreach (var choice in question.QuestionChoices)
                                        {
                                            <div class="databox radius-bordered bg-lightgray">
                                                <div class="databox-right bg-blueberry">
                                                    <div class="databox-piechart">
                                                        <div data-toggle="easypiechart" class="easyPieChart" data-barcolor="#fff" data-linecap="butt" data-percent="50" data-animate="500" data-linewidth="3" data-size="47" data-trackcolor="rgba(255,255,255,0.1)" style="width: 47px; height: 47px; line-height: 47px;">
                                                            <span class="white font-90">@choice.AnswerChoices.Count</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="databox-left">
                                                    <span class="databox-number blueberry"><a style="color: inherit">@choice.Text </a></span>
                                                    <div class="databox-text darkgray"></div>
                                                </div>
                                            </div>
                                        }

in top code look at : @choice.Text and result:

<div class="databox radius-bordered bg-lightgray">
                                                <div class="databox-right bg-blueberry">
                                                    <div class="databox-piechart">
                                                        <div data-toggle="easypiechart" class="easyPieChart" data-barcolor="#fff" data-linecap="butt" data-percent="50" data-animate="500" data-linewidth="3" data-size="47" data-trackcolor="rgba(255,255,255,0.1)" style="width: 47px; height: 47px; line-height: 47px;">
                                                            <span class="white font-90">0</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="databox-left">
                                                    <span class="databox-number blueberry"><a style="color: inherit">&#x6AF;&#x632;&#x6CC;&#x646;&#x647; 1 </a></span>
                                                    <div class="databox-text darkgray"></div>
                                                </div>
                                            </div>
                                            <div class="databox radius-bordered bg-lightgray">
                                                <div class="databox-right bg-blueberry">
                                                    <div class="databox-piechart">
                                                        <div data-toggle="easypiechart" class="easyPieChart" data-barcolor="#fff" data-linecap="butt" data-percent="50" data-animate="500" data-linewidth="3" data-size="47" data-trackcolor="rgba(255,255,255,0.1)" style="width: 47px; height: 47px; line-height: 47px;">
                                                            <span class="white font-90">1</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="databox-left">
                                                    <span class="databox-number blueberry"><a style="color: inherit">&#x6AF;&#x632;&#x6CC;&#x646;&#x647;2 </a></span>
                                                    <div class="databox-text darkgray"></div>
                                                </div>
                                            </div>

now in top html rendered a (گزینه 2) as a code how i can fix this issue?

my code is in C# and Asp.net Core. tnx.

3
  • Very unclear what you are asking... So far you've highlighted valid looking HTML (6xx are plausible to be Persian characters)... Could you please edit post and show HTML as text (instead of images) and more importantly what you expecting to see (presumably instead of valid HTML shown in the post currently). Commented Apr 2, 2020 at 17:25
  • @AlexeiLevenkov hi, edited Commented Apr 2, 2020 at 17:35
  • .NET strings are Unicode. The page you read is a Unicode page generated by ASP.NET without any kind of special handling or encoding. You could type Chinese or Arabic characters without any problem. Where does the text come from? It seems like it was encoded in the controller Commented Aug 24, 2020 at 9:34

2 Answers 2

1
 services.AddSingleton<HtmlEncoder>(
            HtmlEncoder.Create(allowedRanges: new[] { UnicodeRanges.BasicLatin,
                UnicodeRanges.Arabic }));
Sign up to request clarification or add additional context in comments.

2 Comments

Or avoid HTML encoding completely. .NET strings are Unicode. This page you read is Unicode. You could type Arabic or Chinese text in a question or comment and have it displayed without any kind of encoding
In fact, I see your question contains Arabic already, so you've proved yourself that HtmlEncoder is not needed. You should remove any encoding attempt in your action code (which is missing from the question)
0

It looks like you are using a component called "easypiechart" which is not displaying the characters correctly. Is that right?

You must talk to the easypiechart programmers and find a way to fix the problem.

The problem does not seem to be with asp.net core.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.