0

I am using cmder console with powershell and creating a custom prompt. So I creae a task that looks like this:

*PowerShell -ExecutionPolicy Bypass -NoLogo -NoExit -new_console:d:"%USERPROFILE%"

Now inside Microsoft.PowerShell_profile.ps1 I create a prompt that looks like:

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

function prompt
{
    Write-Host "➜"  -nonewline -foregroundcolor Magenta 
}

Now the prompt outputs:

âžœPS>

So my is not outputting correct. So I copy

âžœPS>function prompt { Write-Host "➜"  -nonewline -foregroundcolor Magenta }

and paste it right into cmder prompt and now the prompt outputs

➜PS>

as it should. How can I get cmder to output UTF8 at the command prompt when putting it in Microsoft.PowerShell_profile.ps1?

null_pointer
  • 1,779
  • 4
  • 19
  • 38

1 Answers1

1

Based on @PetSerAl responses I did need to save the file as UTF8 with BOM.

I am also able to remove Console]::OutputEncoding = [System.Text.Encoding]::UTF8 from my Microsoft.PowerShell_profile.ps1. Now my Microsoft.PowerShell_profile.ps1 looks like:

function prompt
{
    Write-Host "➜"  -nonewline -foregroundcolor Magenta 
}
null_pointer
  • 1,779
  • 4
  • 19
  • 38