We have studied the Cu-2p core level photoemission spectrum of a variety of cuprates, mainly focusing on the chemical shift and the shape of the leading peak. The spectra are calculated using the Anderson impurity model and we obtain a very good agreement with the experimental data. We find that the shape of the leading peak depends crucially on the structure of the Cu-O network. The main peak turns out to be quite narrow if the network consists of Cu-O-Cu bond angels of the order of 90°. On the other hand, if the Cu-O atoms are arranged with bond angles of approximately 180°, the main peak becomes substantially broader and contains a rather complicated structure. However, in some cases it is not sufficient only to consider the Cu-O network because interactions with other atoms are also important. In the model compounds Cu2O, CuO and NaCuO2, where Cu is formally monovalent, divalent and trivalent, respectively, we find that the number of 3d electrons is rather similar. Nevertheless, the binding energy increases with the valence as expected from chemical intuition. The spectra exhibit a large variation in the strength of the d9-like satellite and in the width of the main line. We, furthermore, study the chemical shift of three inequivalent Cu atoms in YBa2Cu3O6.5, and compare the results with the model compounds, which suggests that the different Cu atoms in YBa2Cu3O6.5 have formal valences of approximately one, two and three. These findings are analyzed and related to the formal valence.