Microsoft interview question

Write a function that performs run-length encoding on a string.