Fix #1511 by choosing original encoding appropriately.

The new logic here chooses the original (format) string's encoding
when appending a US-ASCII string if the format string contains
non-ASCII characters or its encoding is not ASCII compatible.