How can charge be determined?
There are quite a few different methods in use, all of which have their pros and cons. 

One of the simplest is to just measure the voltage out of the battery. As the battery is being charged or dischared, the output voltge will vary, as demonstrated in this graph from digikey:



Of course, the curve will vary wildly by types of batteries as well as temperature and other conditions.

Another method I have seen used is to monitor the current draw from the battery by means of a very small resistor and current sense amplifier. By knowing how much capacity should be in the battery, and knowing how long the battery has been operated at specific current levels, one could estimate how much charge is remaining.

These are just a couple of basic examples. There are many integrated chips and circuits designed specifically for the purpose of monitoring power consumption.

A more detailed explanation can be found at Battery University.