I am looking for the best linux library that will allow me to detect string encoding. any idea?
ICU is a good library, you can use ucsdet_detect or ucsdet_detectAll to detect "possible" matches in the encoding of the input buffer.