Function "get_encoded_string" update

I've simplified "get_encoded_string" function. Now you have more control
over the encoding.