A characterization of the symmetric square of a curve