C.UTF-8 does not exist on macOS, causing the terminal to fall back to ASCII encoding when LANG is unset. Use en_US.UTF-8 on macOS and C.UTF-8 on Linux. Also set LC_CTYPE with the platform-appropriate value (UTF-8 on macOS, C.UTF-8 on Linux) for additional safety.