I have a DataGrid
($myWindow.myDataGrid.Items
) that I am trying to Export-Clixml
. The $myWindow.myDataGrid.Items
is an ItemCollection
that contains String
properties that are words with certain characters, like "C‘Thun" or "—Hello". To access the string I am currently looking at, I type $myWindow.myDataGrid.Items[0].Title
and that would give me the string "C‘Thun".
The command I used was:
$myWindow.myDataGrid.Items | Export-Clixml -path $path
When it's exported, they are translated into other characters. In notepad++, the "‘" and "—" show up as "x91" and "x97" respectively. I checked the array before exporting it and the text is accurate, but after exporting, I check the XML file and the text is all converted. I need to retain all the original characters.
I then used this command, to Import-Clixml
back into my DataGrid
:
$Global:items = [Object[]]Import-Clixml -path $path
$myWindow.myDataGrid.ItemsSource = $Global:items
I put a breakpoint at $Global:items = [Object[]]Import-Clixml -path $path
to see what the value at $Global:items[0].title
is when it gets imported and sure enough, it is a ?
. And the values in the DataGrid
are also ?
.
I'm on powershell version 4.
EDIT: Changed some details. Sorry for the trouble. I am on 2 different systems and cannot copy and paste.