1

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?

3
  • 2
    Write-Host certainly supports unicode, what file encoding does your script itself have? Commented Dec 9, 2021 at 13:47
  • I'm supposing this happens on Windows Powershell not Core, right? Commented Dec 9, 2021 at 14:08
  • It works fine in the ise. The console just can't display it. Commented Dec 9, 2021 at 14:24

1 Answer 1

2

Fixed

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()

enter image description here

Before

enter image description here

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.

enter image description here

There's utf8 that doesn't work on the term, that wt supports (both using the cascadia code pl font

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.