Reputation: 443
When I use Write-Host
in my PowerShell script, the output looks like this: ????? ?????.
This happens because I'm entering strings in Arabic with Write-Host
, and it seems that PowerShell doesn't support Arabic...
How do I print text using Write-Host
, but in unicode UTF-8
(which supports Arabic).
Example: Write-Host "مرحباً بالعالم"
The output in this case will be: ????? ?????
Any solutions?
Upvotes: 1
Views: 3644
Reputation: 7501
You need to set a font that supports those characters. Like Cascadia Code PL
Note: The non-PL version didn't work, so get the PL one.
You might have to set the console encoding as well. Unless you really need a different encoding, default to utf8
is a good idea.
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
I didn't actually need wt
here, I'd suggest it. windowsterminal is a modern term, which is now an inbox
app. Meaning it's default on windows going forward.
There's utf8
that doesn't work on the term, that wt
supports (both using the cascadia code pl
font
Upvotes: 2