Clean up unicode code in libstd

Cleans up the Unicode code in libstd and libcore. Rebased version of #13770.