Modified decodeCompletely() to accept an encoding parameter.