Added option to serialize strings with an explicit encoding.