Repository navigation
Closed
Description
The saved NEC file depends on the system locale. The number format produces invalid NEC files when a NEC deck is saved by xnec2c.
- Load the following.
CM --- NEC2 Input File created or edited by xnec2c 4.4.12 ---
CE --- End Comments ---
GW 1 101 -1.00000E+01 0.00000E+00 0.00000E+00 1.00000E+01 0.00000E+00 0.00000E+00 1.00000E-03
GE 0 0 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
EX 0 1 51 0 1.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
FR 0 1 0 0 0.70000E+01 1.00000E-01 1.00000E+02 0.00000E+00 0.00000E+00 0.00000E+00
RP 0 37 73 1000 0.00000E+00 0.00000E+00 5.00000E+00 5.00000E+00 0.00000E+00 0.00000E+00
NE 0 10 4 4 -1.80000E+01 -0.60000E+01 -0.60000E+01 4.00000E+00 4.00000E+00 4.00000E+00
NH 0 10 4 4 -1.80000E+01 -0.60000E+01 -0.60000E+01 4.00000E+00 4.00000E+00 4.00000E+00
EN 0 0 0 0 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
- Execute
xnec2with a german locale (for example).
LC_NUMERIC="de_DE.UTF-8" xnec2c
- Load the file from above
- Save the file produces (a comma
,is used as decimal separator instead of a dot.)
CM --- NEC2 Input File created or edited by xnec2c 4.4.12 ---
CE --- End Comments ---
GW 1 101 -1,00000E+01 0,00000E+00 0,00000E+00 1,00000E+01 0,00000E+00 0,00000E+00 1,00000E-03
GE 0 0 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00
EX 0 1 51 0 1,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00
FR 0 1 0 0 7,00000E+00 1,00000E-01 1,00000E+02 0,00000E+00 0,00000E+00 0,00000E+00
RP 0 37 73 1000 0,00000E+00 0,00000E+00 5,00000E+00 5,00000E+00 0,00000E+00 0,00000E+00
NE 0 10 4 4 -1,80000E+01 -6,00000E+00 -6,00000E+00 4,00000E+00 4,00000E+00 4,00000E+00
NH 0 10 4 4 -1,80000E+01 -6,00000E+00 -6,00000E+00 4,00000E+00 4,00000E+00 4,00000E+00
EN 0 0 0 0 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00 0,00000E+00
This file cannot be parsed successfully by nec2c for example. The output format shouldn't depend on the locale.
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix: Ensure NEC file format uses decimal points regardless of locale
KJ7LNW commentedon Dec 17, 2024
You managed to find a bug that was very difficult. I might have found a simple hackfix related to saving, but the proper fix was to convert all string representations of fields in the editor to ints and doubles.
Because this change is so large, there is a risk of error in the implementation. If you are familiar with programming, then I would greatly appreciate your review to see if I missed anything during the data-type refactor.
Before I do a release, please test as follows and see if this fixes your problem. If you can test the graphical NEC2 file editor interface extensively to see if there are any unexpected side effects, then I would appreciate that as well.
hamarituc commentedon Dec 19, 2024
I am happy to confirm the patch works for me. Thanks for the fast fix.
FYI: According to the man-page I would assume that
setlocale(LC_NUMERIC, "");should also work to reset to the default locale and it is not necessary to save the original locale.KJ7LNW commentedon Dec 19, 2024
Excellent!
Interesting, good to know!
fix: Ensure NEC file format uses decimal points regardless of locale
fix: Ensure NEC file format uses decimal points regardless of locale
KJ7LNW commentedon Dec 29, 2024
I merged to the main branch and closed the ticket, so reopen if there is a problem.
Release v4.4.17