Before I go into any detail, I want to point you to some resources. You may or may not have already seen these.
- Encoding Data For HTM Systems
- Encoders NuPIC Wiki
- Scalar and Datetime encoding HTM School episodes
- SDR HTM School episodes:
These resources should answer many of your questions.