As you go through the letters of the message, you check if the letter is in the map.
If it isn't, add it with a mapped integer of 0 and move on to the next letter.
If it is, check the mapped integer. If it's 0, you replace the occurrence with x and change the integer to 1. If the mapped integer is already 1, move on to the next letter.
There are better ways than this, probably. I'd like to see what others have in mind.
However, i have to change the corresponding x back to the same letter again after decryption so i guess maps are out of the picture or correct me if i`m wrong if it can be done with maps.