- function taken from posh-github, allow us to reliably select the appropriate encoding for writing to $PROFILE