Converting encoded_str to a string so that str_replace won't break