Core electrons as probes of the net-charge distribution in molecules: a case study