Made str and encoding protected, added getEncoding
Neither should be private, so as to allow users to easily extend the
class