- 1 year ago
On Windows, PowerShell misinterprets non-ASCII characters in mosquitto_sub output
If PowerShell is misinterpreting non-ASCII characters in the output of mosquitto_sub
(a MQTT subscriber), you can try changing the PowerShell encoding to properly handle those characters. By default, PowerShell uses the ASCII encoding, which may cause issues with non-ASCII characters.
Here's how you can change the PowerShell encoding to UTF-8 to correctly display non-ASCII characters:
Open PowerShell.
Run the following command to change the default output encoding to UTF-8:
powershell$OutputEncoding = [System.Text.Encoding]::UTF8
Now, when you run the
mosquitto_sub
command and receive non-ASCII characters in the output, PowerShell should interpret them correctly.
If you're running a script that invokes mosquitto_sub
and encounters encoding issues, you can include the encoding change within the script itself to ensure it applies when executing the command.
powershell$OutputEncoding = [System.Text.Encoding]::UTF8
# Execute mosquitto_sub command
By setting the $OutputEncoding
variable to UTF-8, PowerShell will use the appropriate encoding to display non-ASCII characters correctly.