Last active
November 2, 2024 20:11
-
-
Save ninmonkey/a1e5edd442abf3f2e24c4fdc44b56dd4 to your computer and use it in GitHub Desktop.
Nonsense example. Just showing a round trip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $originalMessage = "hi π world" | |
| $enc = [Text.Encoding]::GetEncoding('utf-8') | |
| $bytes = $enc.GetBytes( $originalMessage) | |
| $hexStr = [Convert]::ToHexString( $bytes ) | |
| $asBytes = [Convert]::FromHexString( $hexStr ) | |
| $roundTrip = $enc.GetString( $AsBytes ) | |
| [pscustomobject]@{ | |
| Original = $originalMessage | |
| Enc = $enc | |
| Bytes = $bytes | |
| HexStr = $hexStr | |
| BytesAgain = $asBytes | |
| RoundTrip = $roundTrip | |
| IsValid = $roundTrip -eq $originalMessage | |
| } | |
| <# | |
| output | |
| Original : hi π world | |
| Enc : System.Text.UTF8Encoding+UTF8EncodingSealed | |
| Bytes : {104, 105, 32, 240β¦} | |
| HexStr : 686920F09F909220776F726C64 | |
| BytesAgain : {104, 105, 32, 240β¦} | |
| RoundTrip : hi π world | |
| IsValid : True | |
| #> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment