Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I'm not sure I understand your counter-example. It seems to me like you could smoothly deform the union of two disjoint sets into $\mathbb{R}$ so that the set where you don't have a diffeomorphism is measure zero. Could you add further details?