  We compute the intersection cohomology of the moduli spaces $M(r,d)$ of
semistable vector bundles of arbitrary rank $r$ and degree $d$ over a curve. To
do this, we introduce new invariants, called Donaldson-Thomas invariants of a
curve, which can be effectively computed by methods going back to Harder,
Narasimhan, Desale and Ramanan. Our main result relates the Hodge-Euler
polynomial of the intersection cohomology of $M(r,d)$ to the Donaldson-Thomas
invariants. More generally, we introduce Donaldson-Thomas classes in the
Grothendieck group of mixed Hodge modules over $M(r,d)$ and relate them to the
class of the intersection complex of $M(r,d)$. Our methods can be applied to
the moduli spaces of objects in arbitrary hereditary categories.
