Charset: Allow _canonical_charset() to handle mixed-case strings.
_canonical_charset()
Add improved unit tests, and collect existing unit tests together.
Props pbearne. Fixes #38337.