A person charged with a misdemeanor, who is unable to furnish a recognizance or bail bond with satisfactory sureties, may, after being committed to jail, elect to labor as provided for by this article. The circuit, criminal or intermediate court of any county, or the judge thereof in vacation, may, in its discretion, enter an order permitting such person to labor as provided for in this article until a time to be fixed in the order.
If at the trial such person is convicted and sentenced to imprisonment in the county jail, or to labor as specified in this article, he shall be credited on his term with the number of days already labored. If fined, he shall be credited on the fine and costs with $1 per day for each day he has labored. If acquitted, he shall be paid out of the general county funds $1 per day for each day he has labored.