Compute character frequency in a string