This came up before in
What encoding am I (probably) using?, but it sounds like in your case you are just choosing between latin1 and utf8? If so, the best way may be to just check if it is valid utf8, and only if it
isn't assume it is latin1. You can simply use utf8::decode to do this.