Josh Jersild on Nostr: npub16y5jd…wym3t C# actually has one critical flaw in my mind with strings, is that ...
npub16y5jdh5pxyqcvknyw70n2l5sr725zhv0n46mtr5lkmr0uz4xsnlqywym3t (npub16y5…ym3t) C# actually has one critical flaw in my mind with strings, is that its strings are just effectively arrays of UTF-16 code units. UTF-16 is (imo) bad as a raw representation because it's *almost* always correct - almost every Unicode character (especially those in most common languages) fits in a single utf-16 unit, so it's easy to get complacent about "oh this thing might only be half of a true Unicode character" and then you end up splitting a string mid-character and the Problems start.
If everything fit cleanly in UTF-16, though, yeah, it's otherwise great to use! Really a smart choice to effectively treat them as immutable values, eliminates a whole class of having to reason through "am I changing this string or making a new one" issues.
Published at
2023-05-23 21:57:02Event JSON
{
"id": "8d9940ee631801ded42908a0862eea8cffbd241559ced22be562293de110a725",
"pubkey": "0750d612a3ccaac1629c61dc95889c77a3d9f849da81ca27a1d4e5af4c1b17dd",
"created_at": 1684879022,
"kind": 1,
"tags": [
[
"p",
"d12926de813101865a64779f357e901f95415d8f9d75b58e9fb6c6fe0aa684fe",
"wss://relay.mostr.pub"
],
[
"p",
"d92867c70ffee0c3c237c79bef0c35790709845fe419ef5f04793e3385833491",
"wss://relay.mostr.pub"
],
[
"e",
"75149ff9e9c8c326bd971108b9a25ffa626f0c7806ae8d18b2e55042d96b8bb7",
"wss://relay.mostr.pub",
"reply"
],
[
"mostr",
"https://peoplemaking.games/users/JoshJers/statuses/110420231609519834"
]
],
"content": "nostr:npub16y5jdh5pxyqcvknyw70n2l5sr725zhv0n46mtr5lkmr0uz4xsnlqywym3t C# actually has one critical flaw in my mind with strings, is that its strings are just effectively arrays of UTF-16 code units. UTF-16 is (imo) bad as a raw representation because it's *almost* always correct - almost every Unicode character (especially those in most common languages) fits in a single utf-16 unit, so it's easy to get complacent about \"oh this thing might only be half of a true Unicode character\" and then you end up splitting a string mid-character and the Problems start.\n\nIf everything fit cleanly in UTF-16, though, yeah, it's otherwise great to use! Really a smart choice to effectively treat them as immutable values, eliminates a whole class of having to reason through \"am I changing this string or making a new one\" issues.",
"sig": "2b6c082d54cb95f57369279c3869770efab6edfc50051aeb7af8a76839a14be89460ae468957337aac49c62006598d3730b8b918b3b892f6826e2a4e0c40f5d7"
}