In any case in which, pursuant to this chapter, the court appoints counsel to represent any person who desires but is unable to employ counsel, counsel shall receive a reasonable sum for compensation and for necessary expenses, the amount of which shall be determined by the court, to be paid out of the general fund of the county.