From aae5d799961451b8333a0da4e7f5e07c48bd48cc Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Tue, 14 May 2024 02:37:25 -0500 Subject: [PATCH] Update UtilsForUnicodeStrings.psm1 --- Pwsh/Unicode/UtilsForUnicodeStrings.psm1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Pwsh/Unicode/UtilsForUnicodeStrings.psm1 b/Pwsh/Unicode/UtilsForUnicodeStrings.psm1 index 07c5654..ba5a04f 100644 --- a/Pwsh/Unicode/UtilsForUnicodeStrings.psm1 +++ b/Pwsh/Unicode/UtilsForUnicodeStrings.psm1 @@ -1,4 +1,6 @@ -function UnicodeLength { +# Text.Rune and other features used require Pwsh7+ + + function UnicodeLength { <# .SYNOPSIS this gives the "length" of a string in terms of codepoints (aka runes) @@ -30,6 +32,14 @@ function ShowHex { # $Input | join-string -f '{0:x}' } +filter ShowUni { + # sugar. nothing to see here... + ($_ ?? '').EnumerateRunes() + | Join-string -f "`n- {0}" -p { + $_.Value.ToString('x'), $_ + } +} + $script:Enc8 = [Text.Encoding]::GetEncoding('utf-8') $script:Enc16 = [Text.Encoding]::GetEncoding('utf-16le')