The county court of each county, or tribunal created in lieu thereof, shall have authority to provide for and pay to any city, town or village in this state in which no county jail or other place of imprisonment is owned by the county, not more than one dollar fifty cents for the first day and not more than one dollar for each subsequent day that any person charged with a criminal offense may be temporarily held in the jail or lockup belonging to such city, town or village: Provided, That the provisions of this paragraph shall not apply to any person imprisoned for a violation of the ordinances of any city, town or village: Provided further, That in no case shall such payment be made for a period of more than five days for the detention of any one person held under any charge or charges at any one time. No such payment shall be made unless the amount of such charge is certified by the justice or other authority under whose jurisdiction such person is detained in the same manner as other costs in criminal cases are now required by law to be certified. The payment provided for in this section shall be made, in cases of persons charged with felonies or misdemeanors, in the manner and from the proper fund, according to the character of the offense charged, as provided by law for the payment of other costs payable by the county courts in criminal cases.