Joel Bennett on Nostr: I've been playing with strings in #dotnet and #PowerShell trying to determine how ...
I've been playing with strings in #dotnet and #PowerShell trying to determine how long strings are (or appear to be), in a terminal.
As an exercise, I tried to make Windows PowerShell compatible version of Measure-String that:
1. Properly ignores ANSI escape sequences (better than current $Host.UI.RawUI.LengthInBufferCells)
2. Properly account for UAX29 (e.g. the 19-char long šØš»āš©š¼āš§š¼āš§š¼ emoji)
#ProTip: it's not worth it to try and do _ANYTHING_ in Unicode in .NET Framework 4.x
Published at
2024-10-21 06:40:35 UTCEvent JSON
{
"id": "879870a1ef35ba570635598083d7c8163d3b3df1b786b7a854682f5f90e5cf5b",
"pubkey": "3b40d582273fa3ead266583aa152add053d40af980733b30187021b20fe40947",
"created_at": 1729492835,
"kind": 1,
"tags": [
[
"t",
"protip"
],
[
"proxy",
"https://fosstodon.org/@jaykul/113344042463721565",
"web"
],
[
"t",
"dotnet"
],
[
"t",
"powershell"
],
[
"proxy",
"https://fosstodon.org/users/jaykul/statuses/113344042463721565",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://fosstodon.org/users/jaykul/statuses/113344042463721565",
"pink.momostr"
],
[
"-"
]
],
"content": "I've been playing with strings in #dotnet and #PowerShell trying to determine how long strings are (or appear to be), in a terminal.\n\nAs an exercise, I tried to make Windows PowerShell compatible version of Measure-String that:\n\n1. Properly ignores ANSI escape sequences (better than current $Host.UI.RawUI.LengthInBufferCells)\n2. Properly account for UAX29 (e.g. the 19-char long šØš»āš©š¼āš§š¼āš§š¼ emoji)\n\n#ProTip: it's not worth it to try and do _ANYTHING_ in Unicode in .NET Framework 4.x",
"sig": "8c38b3f5142e9573f82e7b47532e3f727513e01c81d6f94ae17c370be7254660aa3c9847fc1f7e17e3d516e9f0a0a8bfbbdea35c698c171414291a3595a416ee"
}