-1

Actually i make one test unit that print this result:

info: serving app on http://127.0.0.1:4000

  Usuario
superagent: Enable experimental feature http2
    ✓ realiza um registro de usuário (511ms)
    ✓ realiza login com o usuário registrado (142ms)
    ✓ realiza login com dados incorretos (145ms)

   PASSED 

  total       : 3
  passed      : 3
  time        : 2s

If i try to export this log in format .txt i have several problems with special characters and accents, as you can see:

adonis test > yourfile.txt

When i open the "yourfile.txt":

[32minfo[39m: serving app on http://127.0.0.1:4000

  Usuario
    Ô£ô realiza um registro de usu├írio (456ms)
    Ô£ô realiza login com o usu├írio registrado (135ms)
    Ô£ô realiza login com dados incorretos (126ms)

   PASSED 

  total       : 3
  passed      : 3
  time        : 1s

I'm thinking if there's a way to export this log in pdf to workaround this problem or if there's a way to show the special characters/accents correctly.

if i do a adonis test > yourfile.pdf the pdf generated is broken.

bla
  • 995
  • 3
  • 11
  • 44
  • Possible duplicate of [Basic Powershell - batch convert Word Docx to PDF](https://stackoverflow.com/questions/16534292/basic-powershell-batch-convert-word-docx-to-pdf) – Matthew Oct 31 '19 at 11:15
  • @Matthew thanks but this question is about to convert docx -> pdf, in my case is txt -> pdf, if i try to save using .docx i have the same problem (archive is broken) – bla Oct 31 '19 at 11:20
  • Instead of redirecting with `>`, assign into a variable and use [Add-Content](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/add-content?view=powershell-6)? – vonPryz Oct 31 '19 at 11:29
  • If not that, perhaps this one: https://stackoverflow.com/questions/23892631/convert-text-file-to-pdf-file-using-powershell – Matthew Oct 31 '19 at 11:44

1 Answers1

2

This may have to do with OutputEncoding.
Try:

$enc = [Console]::OutputEncoding
[Console]::OutputEncoding = [text.encoding]::utf8

adonis test | Out-File yourfile.txt -Encoding utf8 -Force

[Console]::OutputEncoding = $enc
Theo
  • 57,719
  • 8
  • 24
  • 41