I’m making an online game where users can enter a name. However, I want every user to have a name. I have made it so that it detects if they didn’t put a name in, but I’m not sure how to detect if they put only spaces in to try to get around it.
Is this a local game or a network game? If it’s going to be networked, users putting in only spaces is the least of your worries when it comes to vetting names…
As for the space thing, it can get complicated; unicode has a whole variety of whitespace characters, and you also potentially have the whole question of broken unicode; for example, what happens if someone abuses combining characters…
To @hexgrid 's point, if you want to really check this, you should be using a Regular Expression (RegEx) that is constructed to strip out unwanted characters. It can also check for spaces for you.