1

Recently I have come across the following article: Powershell comparison operators [...]

It basically states that

"Peter" -gt "Paul"

evaluates to TRUE because both strings are compared character by character, and as soon as a character differs, the string which contains the character with the higher ASCII value is considered to be greater than the other one.

I have verified (by testing a fairly large amount of examples) that this is true, and have understood how it works.

However, I now would like to know how this works with non-ASCII characters, especially with strings which only consist of one single character. For example,

'δΊ‹' -gt 'ζœƒ'

evaluates to FALSE, but I have no clue why. Please note that I don't know a single Chinese letter or word; I just have opened a website which contained a few Chinese characters, have randomly chosen two of them, and have pasted them into the Powershell console. I have chosen Chinese characters because they are neither in the ASCII nor in the extended ASCII range, and are encoded by at least two bytes in any encoding I am aware of.

How does Powershell compare such characters and strings? By Unicode code points? By ordering according to the current user's locale's rules? By the literal byte values in the binary representation of the encoded string? In the latter case, what is the default encoding?

Microsoft's documentation does not tell anything about it.

Binarus
  • 4,005
  • 3
  • 25
  • 41
  • Thank you very much for the link! The question is nearly completely different from mine (the first part deals with case sensitivity, which I don't have an issue with, the second part deals with string vs. character which isn't my issue either). However, the accepted answer straightly answers my question! What a pity that I hadn't found it when doing my research. – Binarus Nov 30 '20 at 19:54

0 Answers0