Wrong encoding on PowerShell Invoke-WebRequest POST

前端 未结 2 447
难免孤独
难免孤独 2020-12-15 08:11

I\'m using Invoke-WebRequest POST method to send an text data. After sending the text in a wrong encoding.

Script:

$postData = \"žluťoučký kůň úpěl ď         


        
2条回答
  •  不思量自难忘°
    2020-12-15 08:52

    This worked for me:

    $postData = "žluťoučký kůň úpěl ďábelské ódy"
    Invoke-WebRequest -Uri 'http://www.example.com/' -Method Post -Body $postData 
     -ContentType "text/plain; charset=utf-8"
    

    Adding the charset=utf-8 fixed my issue where the acute accent characters were getting converted to special symbols.

提交回复
热议问题