Thanks Jim ~
We actually do use code very similar to this. If you follow the article, at one point it does also indicate that you have to make a choice about what to default to if you are unable to detect a specific Unicode format by the Byte Order Mark (BOM), which is not always present. We have chosen to default to an expectation of UTF-8, rather than ASCII, since we have a significant installed base internationally and will be fully supporting internationalization in the application. Windows default is also, I believe, UTF-8... so should make sense most of the time.
It's pretty non-trivial, and these decisions are not made arbitrarily. If someone has another working solution... tested under many scenarios... we would welcome a look at it.
Cheers,
Scott
Scott Willhite
It is only with the heart that one can see rightly... what is essential is invisible to the eye.
~ Antoine de Saint-Exup?ry