❔ How to fix encoding in Razor View?

Hello, I want to show error as JS alert
@if (ViewBag.Error != null)
{
var error = ViewBag.Error as ErrorViewModel;
<script>
alert("@error.Message");
</script>
}
@if (ViewBag.Error != null)
{
var error = ViewBag.Error as ErrorViewModel;
<script>
alert("@error.Message");
</script>
}
message contains polish characters and I got this as shown on picture. How to fix encoding to show polish characters correctly. I have set meta charset as UTF-8
5 Replies
The Fog from Human Resources
Try UTF-16 maybe?
Ⰽⰰⱈⰻⰽⱄ
ⰍⰰⱈⰻⰽⱄOP17mo ago
still similiar issue
Angius
Angius17mo ago
UTF-8 should be enough The only thing wrong so far is the use of ViewBag It's shit, yes, but not so shit to influence character encoding Is the encoding set in the HTML metadata as well? The lang attribute maybe?
Ⰽⰰⱈⰻⰽⱄ
ⰍⰰⱈⰻⰽⱄOP17mo ago
yes, it's utf-8 and lang set to pl
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server