0

I have a datatable with Locale nb-NO and TextInfo ANSICodePage 1252. I run the following code:

IEnumerable<DataRow> ieDatarow = (from row in dtDatatable.AsEnumerable()
                                  where row.ItemArray[row.Table.Columns.IndexOf(strColumn)].ToString() == strValue && row.ItemArray[2].ToString() != "strServiceAccount"
                                  select row).OrderByDescending(x => x.ItemArray[0]).Distinct();

Looking at the data in ieDatarow, strings with characters like æ, ø and å become like this: "ø"

With this code the characters do not change:

IEnumerable<DataRow> ieDatarow = ArgDatatable.AsEnumerable().OrderByDescending(x => x.ItemArray[0]).Distinct()

How can I retain the encoding from the datatable?

Nihth
  • 3
  • 1
  • the answer in this question may be of some use to you http://stackoverflow.com/questions/8404367/how-to-read-a-string-with-utf8-coding-using-linq-to-entities – Simon Price Oct 19 '16 at 12:10
  • Thank you that solved it! Encoding.UTF8.GetString(Encoding.Default.GetBytes(yourstring)) – Nihth Oct 19 '16 at 12:22

0 Answers0