Thursday, 29 January 2015

Breaking The Declaration

The snippet of powershell below is useful for trading partners who declare an xml document with
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
Then go ahead and use invalid characters that are not part of UTF-8.

foreach($i in get-childitem testfolder/test*.xml) {
$dest = $i.Fullname.Replace("testfolder","productionfolder/in")
get-content $i | out-file -encoding utf8 -filepath $dest
rm $i
What this does is setup a destination path variable and outputs a file to that destination. In the process it parses the file to ensure it's all UTF-8.

No comments:

Post a Comment