Yes, this was obligated by treaties governing the care of POWs, in particular the Geneva Convention on Prisoners of War, 1929, and in the West, was generally followed. For the prisoners held by the USA, which generally followed the rules the best, I touch on this a bit more in this answer.