question

ratrace-8036 avatar image
0 Votes"
ratrace-8036 asked IanXue-MSFT edited

Poweshell - Greek characters in $profile script

Hello,

in $profile file i wrote the function below.

function gr {cd c:\users\user\documents\γραφειο}

When i'm running the fuction in powershell the outcome is,

PS C:\Users\User> gr
cd : Cannot find path 'C:\users\user\documents\Ξ³Οαφειο\' because it does not exist.
At C:\Users\User\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:1 char:14
+ function gr {cd c:\users\user\documents\Ξ³Οαφειο}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\users\user\documents\Ξ³Οαφειο\:String) [Set-Location], ItemNot
FoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

PS C:\Users\User>

What can i do so that the Greek characters in path are correctly recognized?

I'm using windows 10 and windows terminal.

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

Hi,

What is the encoding of your profile? You can try setting it to UTF-8.

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ratrace-8036 avatar image
0 Votes"
ratrace-8036 answered

Hello @IanXue-MSFT ,

when i'm giving this script that i found in microsoft help page,

[psobject].Assembly.GetTypes() | Where-Object { $.Name -eq 'ClrFacade'} |
ForEach-Object {
$
.GetMethod('GetDefaultEncoding', [System.Reflection.BindingFlags]'nonpublic,static').Invoke($null, @())
}

the outcome is,

IsSingleByte : True
BodyName : iso-8859-7
EncodingName : Ελληνικά (Windows)
HeaderName : windows-1253
WebName : windows-1253
WindowsCodePage : 1253
IsBrowserDisplay : True
IsBrowserSave : True
IsMailNewsDisplay : True
IsMailNewsSave : True
EncoderFallback : System.Text.InternalEncoderBestFitFallback
DecoderFallback : System.Text.InternalDecoderBestFitFallback
IsReadOnly : True
CodePage : 1253

When i'm opening the $profile file,

notepad.exe $PROFILE

at the bottom of the notepad shows Windows (CRLF) | UTF-8.

How can i change the encoding of my profile?

Thank you

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

Hi,

To change the encoding to UTF-8, you can run "chcp 65001". Add this line to the profile if you want to use UTF-8 by default.
https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.