Succinct Encoding of Permutations: Applications to Text Indexing