added detectEncoding option