How can I display utf8 in powershell?

2

So this really has me knocking my head against the wall. I have some XML:

  <trans-unit id="4" translate="yes" xml:space="preserve">
    <source xml:lang="en-US">Customize Forecast (Outstanding) by Customer Detail</source>
    <target>Настроить просроченный прогноз по клиентам (подробно)</target>
  </trans-unit>
  <trans-unit id="5" translate="yes" xml:space="preserve">
    <source xml:lang="en-US">Posting Period</source>
    <target>Период разнесения</target>
  </trans-unit>

I want to extract the Russian text to a file. I load the XML into [xml]$mf and do:

$mf.xliff.file.body.trans-unit.target

Trouble is that that renders as:

Выполнена ÑÐ¸Ð½Ñ…Ñ€Ð¾Ð½Ð¸Ð·Ð°Ñ†Ð¸Ñ Ñервера машин вложенного ÑпиÑка Файл PDF Полный CSV-ÑкÑпорт Ð´Ð»Ñ Ð´Ð°Ð½Ð½Ñ‹Ñ… учета {1} ÐšÐ°Ñ‚ÐµÐ³Ð¾Ñ€Ð¸Ñ Ð±ÑŽÐ´Ð¶ÐµÑ‚Ð° Показать Ñтроки Ð’Ñ‹Ð±Ñ€Ð°Ð½Ð½Ð°Ñ ÑƒÑлуга FedEx предуÑматривает только один пакет на отгрузку. ЕÑли заказ Ñодержит неÑÐºÐ¾Ð»Ñ ŒÐºÐ¾ пакетов, оформите каждый пакет как отдельную отгрузку. Закрыта - потерÑна

Which isn't very helpful. I've been googling this for an hour and I'm clearly missing something fairly obvious.

Dan

Posted 2014-04-25T09:17:15.513

Reputation: 142

Answers

2

[xml]$mf = gc .\testxml.txt -Encoding UTF8
$mf.xliff.file.body.'trans-unit'.target | Out-File c:\path\output.txt -Encoding UTF8

Raf

Posted 2014-04-25T09:17:15.513

Reputation: 186

That's it, seems I was approaching the problem from the wrong end. – Dan – 2014-04-25T11:21:20.780

0

Try this

[xml]$mf=Get-Content -Encoding UTF8 file.xml

Andrey

Posted 2014-04-25T09:17:15.513

Reputation: 140