All persons committed to prison before conviction shall be committed to the jail of the county in which the examination is had, or to that of the county in which the offense is charged to have been committed: Provided, if the jails of these counties are unsafe, or injurious to the health of prisoners, the committing magistrate may commit to the jail of any other convenient county. And every sheriff or jailer to whose jail any person shall be committed by any court or magistrate of competent jurisdiction shall receive such prisoner and give a receipt for him, and be bound for his safekeeping as prescribed by law.
N.C. Gen. Stat. § 15-126