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?

2
  • the answer in this question may be of some use to you stackoverflow.com/questions/8404367/… Commented Oct 19, 2016 at 12:10
  • Thank you that solved it! Encoding.UTF8.GetString(Encoding.Default.GetBytes(yourstring)) Commented Oct 19, 2016 at 12:22

0

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.