fix encoding before indexing