BUG: Fix number encoding to use C locale#2297
Merged
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom Feb 15, 2021
Merged
BUG: Fix number encoding to use C locale#2297dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom
Conversation
The floating point number encoding defaults to the C locale on the standard C++ std IO. The sscanf uses the OS dependent LC_NUMERIC value. This fixes that behavior
Closed
dzenanz
reviewed
Feb 12, 2021
Member
dzenanz
left a comment
There was a problem hiding this comment.
Code looks good. Minor style issue: there should be a space between statement and a comment. The in-line suggestion should be applied to all the cases.
malaterre
reviewed
Feb 12, 2021
fixed a missing locale reset. fixed the mentioned styling issues.
dzenanz
approved these changes
Feb 15, 2021
thewtex
added a commit
that referenced
this pull request
Dec 17, 2025
Avoid locale-dependent of floating-point metadata re: #5683, #3375, #2297 Implement locale handling in Modules/IO/NRRD/src/itkNrrdImageIO.cxx using RAII pattern. - Add ScopedCNumericLocale class for automatic locale save/restore - Apply locale protection around nrrdLoad/nrrdSave calls - Add test coverage (itkNrrdLocaleTest.cxx) Co-authored-by: Matt McCormick <matt@fideus.io>
hjmjohnson
pushed a commit
that referenced
this pull request
Jan 23, 2026
Avoid locale-dependent of floating-point metadata re: #5683, #3375, #2297 Implement locale handling in Modules/IO/NRRD/src/itkNrrdImageIO.cxx using RAII pattern. - Add ScopedCNumericLocale class for automatic locale save/restore - Apply locale protection around nrrdLoad/nrrdSave calls - Add test coverage (itkNrrdLocaleTest.cxx) Co-authored-by: Matt McCormick <matt@fideus.io>
hjmjohnson
pushed a commit
that referenced
this pull request
Jan 23, 2026
Avoid locale-dependent of floating-point metadata re: #5683, #3375, #2297 Implement locale handling in Modules/IO/NRRD/src/itkNrrdImageIO.cxx using RAII pattern. - Add ScopedCNumericLocale class for automatic locale save/restore - Add thread-safe NumericLocale utility class. This addresses thread-safety concerns raised in code review. Thread safety implementation: - Windows: Uses _configthreadlocale() for thread-local locale - POSIX (Linux/macOS): Uses newlocale()/uselocale() for thread-local locale - Fallback: Mutex-protected global locale as last resort - Apply locale protection around nrrdLoad/nrrdSave calls - Add test coverage (itkNrrdLocaleTest.cxx) Create thread-safe locale handling in ITKCommon to replace non-thread-safe setlocale() calls. Update NRRD reader to use the new utility. Co-authored-by: Matt McCormick <matt@fideus.io> Co-authored-by: Bradley Lowekamp <blowekamp@mail.nih.gov>
hjmjohnson
pushed a commit
that referenced
this pull request
Jan 23, 2026
Avoid locale-dependent of floating-point metadata re: #5683, #3375, #2297 Implement locale handling in Modules/IO/NRRD/src/itkNrrdImageIO.cxx using RAII pattern. - Add ScopedCNumericLocale class for automatic locale save/restore - Add thread-safe NumericLocale utility class. This addresses thread-safety concerns raised in code review. Thread safety implementation: - Windows: Uses _configthreadlocale() for thread-local locale - POSIX (Linux/macOS): Uses newlocale()/uselocale() for thread-local locale - Fallback: Mutex-protected global locale as last resort - Apply locale protection around nrrdLoad/nrrdSave calls - Add test coverage (itkNrrdLocaleTest.cxx) Create thread-safe locale handling in ITKCommon to replace non-thread-safe setlocale() calls. Update NRRD reader to use the new utility. Co-authored-by: Matt McCormick <matt@fideus.io> Co-authored-by: Bradley Lowekamp <blowekamp@mail.nih.gov>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The floating point number encoding defaults to the C locale on the standard C++ std IO. The sscanf uses the OS dependent LC_NUMERIC value. This fixes that behavior
EDIT
Closes #2067
PR Checklist
Refer to the ITK Software Guide for
further development details if necessary.