title: How to keep UTF-8 encoding when sorting JSON with jq
body: <p>I'm using jq 1.5 on Windows PowerShell to sort the fields of a JSON file in an alphabetically order.</p>
  
  <p>This works quite fine so far but special characters (like ÜÄÖüäö) are not kept in the jq output.</p>
  
  <p>The original file is saved in UTF-8 encoding:</p>
  
  <pre><code>{
    "sha": "18879fb99367924cd76d402e841155bf73c8afb3",
    "commit": {
      "author": {
      "name": "John Doe ÜÄÖ",
      "email": "john@example.com",
      "date": "2017-11-23T07:51:22Z"
      }
    }
  }
  </code></pre>
  
  <p>And this is the jq output saved as UTF-8:</p>
  
  <pre><code>{
    "commit": {
      "author": {
        "date": "2017-11-23T07:51:22Z",
        "email": "john@example.com",
        "name": "John Doe ???"
      }
    },
    "sha": "18879fb99367924cd76d402e841155bf73c8afb3"
  }
  </code></pre>
  
  <p>As you can see the characters ÜÄÖ are not recognized and are saved as ???.</p>
  
  <p>This is how I use jq in PowerShell:</p>
  
  <pre><code>$json = Get-Content .\json.txt -Encoding UTF8
  $jsonSorted = $json | .\jq-win64.exe --sort-keys '.'
  Set-Content jsonSorted.txt -Value $jsonSorted -Encoding UTF8
  </code></pre>