The following expenses of the district attorney and the sheriff are county charges:
(a)
Traveling and other personal expenses incurred in criminal cases arising in the county and in civil actions and proceedings in which the county is interested.
(b)
All other expenses necessarily incurred by either of them:
(1)
In the detection of crime. Except as to violations of Section 23152 of the Vehicle Code, this section does not apply to the detection of those crimes declared to be misdemeanors by the Vehicle Code.
(2)
In the prosecution of criminal cases, and in civil actions and proceedings and all other matters in which the county is interested, or in which any officer or employee, or former officer or employee, of the county is a defendant in an action for damages instituted for any act performed by him or her in good faith in furtherance of his or her duty while in the employ of the county and in which the district attorney is authorized to represent him or her.