The camera does it easily -- it's just that we don't have the same dynamic range available to us in our monitors and in prints.
The "Trick" is to simply expose for the highlights and then compress the dynamic range of the scene using the fill light control in post-processing