I am using a jQuery plug-in to display data. The plug-in basically works on JavaScript arrays. I have written the code as below:
var users = [];
@foreach(MyApp.UserModel um in Model.Users)
{
@:users.push('@um.NameSurname');
}
to push data into a JavaScript array. Actually this code works fine. But I have character issues. Some of the names contain Turkish characters such as "Ş", "Ğ", "Ü", "Ö" which are displayed incorrectly. For example Ç is converted to Ç. In my code I have defined localization as :
<head>
<meta charset="utf-8" lang="tr" />
</head>
and my JavaScript code looks like
users.push('Test ÇADIR');
instead of
users.push('Test ÇADIR');
What am I doing wrong and how can I fix this?
var users = @Html.Raw(Json.Encode(Model.Users))to create an array from your collection property.