I've written this below.
It successfully reverses a string without garbling up any emoji characters.
The only trouble is that it doesn't reverse the emojis which is what I was hoping to do.
Here's the code I have with some examples:
Function Out-ReverseString {
[cmdletbinding()]
Param (
[Parameter(Mandatory = $true, HelpMessage = 'Passed string to reverse')]
[string]$StringInput
)
$returnedNewClip = -join[regex]::Matches($StringInput, '([^\x00-\x7F]+|.)', 'RightToLeft')
return $returnedNewClip
}
Out-ReverseString -StringInput "'What is this?' " # Returns: '?siht si tahW'
Out-ReverseString -StringInput ".sijome ekil I" # Returns: I like emojis.
Out-ReverseString -StringInput ". ekil t'nseod ?néiuQ¿" # Returns: ¿Quién? doesn't like .
Out-ReverseString -StringInput "195981348903269-335" # Returns: 533-962309843189591
Out-ReverseString -String "¿Quién doesn't like ?" # Returns: ? ekil t'nseod néiuQ¿