ModernUO/Projects/UOContent/Gumps
Kamron Batman 0404251638
feat: Adds Latin1 text support (#2317)
## Summary

- Adds proper Latin1 encoding support, replacing CP1252 usage throughout the codebase
- Adds specialized, optimized string decoding methods with safe string filtering for each encoding type
- Filters invalid Unicode characters (C0/C1 control codes, non-characters) by removal rather than replacement since
the UO client renders nothing for these characters
- Fixes UTF-16 null terminator position handling to correctly advance by 2 bytes

## Changes

TextEncoding.cs

- Added SearchValues-based invalid byte/char detection for efficient filtering
- Added encoding-specific GetString methods: GetStringAscii, GetStringLatin1, GetStringUtf8, GetStringBigUni,
GetStringLittleUni
- Each method supports a safeString parameter for filtering invalid characters
- Little-endian UTF-16 uses direct memory cast for zero-copy decoding on LE systems
- Invalid characters are removed (not replaced with U+FFFD) since the client renders nothing for them

SpanReader.cs

- Added ReadLatin1() and ReadLatin1Safe() methods
- Rewrote encoding-specific read methods to use optimized TextEncoding.GetString* methods
- Fixed UTF-16 null terminator handling: position now correctly advances by byteLength (2) instead of 1

SpanWriter.cs

- Added WriteLatin1 and WriteLatin1Null methods

## Packet Updates

- Updated all packet code to use Latin1 encoding instead of CP1252
- Affected: account packets, equipment packets, menu packets, message packets, mobile packets, player packets, secure
trade packets, vendor packets, gump packets, book packets, mahjong packets

## Filtering Behavior

Invalid characters filtered in safe mode:
```
┌───────────────┬────────────────────────┐
│     Range     │      Description       │
├───────────────┼────────────────────────┤
│ 0x00-0x1F     │ C0 control codes       │
├───────────────┼────────────────────────┤
│ 0x7F          │ DEL                    │
├───────────────┼────────────────────────┤
│ 0x80-0x9F     │ C1 control codes       │
├───────────────┼────────────────────────┤
│ 0xFFFE-0xFFFF │ Unicode non-characters │
└───────────────┴────────────────────────┘
```

Note: Surrogate pairs (0xD800-0xDFFF) are not filtered because proper validation requires context checking for paired
vs unpaired surrogates. The UO client renders nothing for these anyway.

## Test Plan

- All 631 Server.Tests pass
- Verified client rendering behavior using TestUnicodeGump command (pages 1-5)
- Confirmed U+FFFD, unpaired surrogates, and non-characters all render as blank in client
- Verified Latin1 characters (0xA0-0xFF) display correctly
- Verified C1 control codes (0x80-0x9F) are filtered and don't display
2026-01-22 15:51:00 -08:00
..
Base feat: Adds Latin1 text support (#2317) 2026-01-22 15:51:00 -08:00
Go chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Guilds chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Houses fix: Eliminates List allocations in various places. (#2158) 2025-11-16 18:33:53 -08:00
Props fix: Fixes props gump for interfaces again (#2180) 2025-05-09 15:44:32 -07:00
AddDoorGump.cs fix: Rewrites AddDoor command, fixes gump and returning to correct page. (#2056) 2025-01-08 10:32:37 -08:00
AdminGump.cs feat: Fixes spawner bugs with position finding, Adds [ShowSpawnerBorders (#2297) 2025-12-28 18:26:03 -08:00
BanDurationGump.cs fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
BaseConfirmGump.cs fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771) 2024-05-10 22:44:16 -07:00
BaseGridGump.cs fix: Consolidates Color/Center html (#1762) 2024-05-07 23:56:32 -07:00
BaseImageTileButtonsGump.cs fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
ClientGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
CommentsGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
ConfirmBreakCrystalGump.cs Fixes brace style (#248) 2020-09-13 21:49:46 -07:00
ConfirmHeritageGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
ConfirmReleaseGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
HeritageTokenGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
NoticeGump.cs fix: Adds static warning/notice gumps. (#1741) 2024-04-26 17:19:16 -07:00
PetResurrectGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
PlayerVendorGumps.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
PolymorphGump.cs fix: Fixes polymorph spell (#2173) 2025-05-04 09:31:32 -07:00
ReclaimVendorGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
ResurrectGump.cs fix: Fixes priced healer resurrection when not choosing the correct option (#2276) 2025-11-23 09:58:33 -08:00
RewardGump.cs feat: Adds item graphic size to Bounds.bin and makes item graphic offset available to gumps (#2115) 2025-02-10 19:31:39 -08:00
RunebookGump.cs fix: Actions on gump crash when Runebook has no entries (#1964) 2024-09-27 10:17:22 -07:00
SelectAddonDirectionGump.cs feat: Standardizes South/East selection gumps (#1839) 2025-02-14 00:15:14 -08:00
SkillsGump.cs fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
StaticNoticeGump.cs fix: Adds static warning/notice gumps. (#1741) 2024-04-26 17:19:16 -07:00
StaticWarningGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
TithingGump.cs fix: Adds missing string interpolation handler for SetStringSlot (#2123) 2025-02-13 19:30:47 -08:00
ToTAdminGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
VendorInventoryGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
VendorRentalGumps.cs chore: Fixes variable types for possible performance issues (#2172) 2025-05-01 21:54:41 -07:00
ViewHousesGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
VirtualCheckGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
WarningGump.cs fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771) 2024-05-10 22:44:16 -07:00
WhoGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
YoungGumps.cs feat: Restyle young player gumps (#1917) 2024-08-10 11:06:18 -07:00