Port the PFM locale fix from #31071 to 5.x, as requested
When the application's C++ locale uses digit grouping, a dimension of 1234 can be written as 1.234 and decoded as 1. Use std::to_string(int) for the integer header fields without changing any locale settings.
This PR only changes the PFM encoder. No new tests are added, following the review of #31071.
Tested on Windows x64 with MSVC 19.42 in Release mode. The existing PFM test passes.