Donald Trump has won the battleground state of Georgia, the onetime Republican stronghold that had voted for Democrats four years ago.