It is unlawful for male and female prisoners in said jails to be confined in the same cell, room, or apartment, or be so confined as to be permitted to commingle, and the sheriffs of this state shall confine and separate all prisoners in their custody or charge in accordance with this chapter.