I've built a PS script to create and populate items from a CSV file. The issue is that chars like ä, ü, ö are replaced with � in the field values. I've changed the encoding from ConvertToDynamicObject()
function from 'Default
' to 'UTF8
', without luck.
The function to read the CSV:
function ReadCSV($media)
{
# get stream and save content to variable $content
[System.IO.Stream]$body = $media.Fields["Blob"].GetBlobStream()
try
{
$contents = New-Object byte[] $body.Length
$body.Read($contents, 0, $body.Length) | Out-Null
}
finally
{
$body.Close()
}
return $contents;
}
Then I convert the byte[] to a Dynamic object:
function ConvertToDynamicObject($contents)
{
# convert to dynamic object
return $csv = [System.Text.Encoding]::Default.GetString($contents) | ConvertFrom-Csv -Delimiter ","
}
Then process the data:
function ImportItem($csv)
{
foreach ($row in $csv)
{
# ...
}
}