Skip to content

Commit 34e2bcc

Browse files
werwolfbyangularsen
authored andcommitted
Read units with UTF8 encoding (#326)
We always write generated files in UTF8, but do not read .json files as UTF8 files. Default Get-Content do not read right some Unicode chars (like Cube (0x0179), Celseum, etc.). Adding Encoding to Get-Content solved the issue.
1 parent f198295 commit 34e2bcc

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

UnitsNet/GeneratedCode/UnitSystem.Default.g.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,82 +2757,82 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
27572757
new CulturesForEnumValue((int) SpecificWeightUnit.KilogramForcePerCubicCentimeter,
27582758
new[]
27592759
{
2760-
new AbbreviationsForCulture("en-US", "kgf/cm³"),
2760+
new AbbreviationsForCulture("en-US", "kgf/cm³"),
27612761
}),
27622762
new CulturesForEnumValue((int) SpecificWeightUnit.KilogramForcePerCubicMeter,
27632763
new[]
27642764
{
2765-
new AbbreviationsForCulture("en-US", "kgf/³"),
2765+
new AbbreviationsForCulture("en-US", "kgf/m³"),
27662766
}),
27672767
new CulturesForEnumValue((int) SpecificWeightUnit.KilogramForcePerCubicMillimeter,
27682768
new[]
27692769
{
2770-
new AbbreviationsForCulture("en-US", "kgf/mm³"),
2770+
new AbbreviationsForCulture("en-US", "kgf/mm³"),
27712771
}),
27722772
new CulturesForEnumValue((int) SpecificWeightUnit.KilonewtonPerCubicCentimeter,
27732773
new[]
27742774
{
2775-
new AbbreviationsForCulture("en-US", "kN/cm³"),
2775+
new AbbreviationsForCulture("en-US", "kN/cm³"),
27762776
}),
27772777
new CulturesForEnumValue((int) SpecificWeightUnit.KilonewtonPerCubicMeter,
27782778
new[]
27792779
{
2780-
new AbbreviationsForCulture("en-US", "kN/³"),
2780+
new AbbreviationsForCulture("en-US", "kN/m³"),
27812781
}),
27822782
new CulturesForEnumValue((int) SpecificWeightUnit.KilonewtonPerCubicMillimeter,
27832783
new[]
27842784
{
2785-
new AbbreviationsForCulture("en-US", "kN/mm³"),
2785+
new AbbreviationsForCulture("en-US", "kN/mm³"),
27862786
}),
27872787
new CulturesForEnumValue((int) SpecificWeightUnit.KilopoundForcePerCubicFoot,
27882788
new[]
27892789
{
2790-
new AbbreviationsForCulture("en-US", "kipf/ft³"),
2790+
new AbbreviationsForCulture("en-US", "kipf/ft³"),
27912791
}),
27922792
new CulturesForEnumValue((int) SpecificWeightUnit.KilopoundForcePerCubicInch,
27932793
new[]
27942794
{
2795-
new AbbreviationsForCulture("en-US", "kipf/in³"),
2795+
new AbbreviationsForCulture("en-US", "kipf/in³"),
27962796
}),
27972797
new CulturesForEnumValue((int) SpecificWeightUnit.NewtonPerCubicCentimeter,
27982798
new[]
27992799
{
2800-
new AbbreviationsForCulture("en-US", "N/cm³"),
2800+
new AbbreviationsForCulture("en-US", "N/cm³"),
28012801
}),
28022802
new CulturesForEnumValue((int) SpecificWeightUnit.NewtonPerCubicMeter,
28032803
new[]
28042804
{
2805-
new AbbreviationsForCulture("en-US", "N/³"),
2805+
new AbbreviationsForCulture("en-US", "N/m³"),
28062806
}),
28072807
new CulturesForEnumValue((int) SpecificWeightUnit.NewtonPerCubicMillimeter,
28082808
new[]
28092809
{
2810-
new AbbreviationsForCulture("en-US", "N/mm³"),
2810+
new AbbreviationsForCulture("en-US", "N/mm³"),
28112811
}),
28122812
new CulturesForEnumValue((int) SpecificWeightUnit.PoundForcePerCubicFoot,
28132813
new[]
28142814
{
2815-
new AbbreviationsForCulture("en-US", "lbf/ft³"),
2815+
new AbbreviationsForCulture("en-US", "lbf/ft³"),
28162816
}),
28172817
new CulturesForEnumValue((int) SpecificWeightUnit.PoundForcePerCubicInch,
28182818
new[]
28192819
{
2820-
new AbbreviationsForCulture("en-US", "lbf/in³"),
2820+
new AbbreviationsForCulture("en-US", "lbf/in³"),
28212821
}),
28222822
new CulturesForEnumValue((int) SpecificWeightUnit.TonneForcePerCubicCentimeter,
28232823
new[]
28242824
{
2825-
new AbbreviationsForCulture("en-US", "tf/cm³"),
2825+
new AbbreviationsForCulture("en-US", "tf/cm³"),
28262826
}),
28272827
new CulturesForEnumValue((int) SpecificWeightUnit.TonneForcePerCubicMeter,
28282828
new[]
28292829
{
2830-
new AbbreviationsForCulture("en-US", "tf/³"),
2830+
new AbbreviationsForCulture("en-US", "tf/m³"),
28312831
}),
28322832
new CulturesForEnumValue((int) SpecificWeightUnit.TonneForcePerCubicMillimeter,
28332833
new[]
28342834
{
2835-
new AbbreviationsForCulture("en-US", "tf/mm³"),
2835+
new AbbreviationsForCulture("en-US", "tf/mm³"),
28362836
}),
28372837
}),
28382838
new UnitLocalization(typeof (SpeedUnit),

UnitsNet/Scripts/GenerateUnits.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ $pad = 25
272272

273273
# Parse unit definitions from .json files and populate properties
274274
$quantities = Get-ChildItem -Path $templatesDir -filter "*.json" `
275-
| %{(Get-Content $_.FullName | Out-String)} `
275+
| %{(Get-Content $_.FullName -Encoding "UTF8" | Out-String)} `
276276
| ConvertFrom-Json `
277277
| Add-PrefixUnits `
278278
| Set-DefaultValues `
@@ -302,4 +302,4 @@ $unitCount = ($quantities | %{$_.Units.Count} | Measure -Sum).Sum
302302
Write-Host "`n`n"
303303
Write-Host -Foreground Yellow "Summary: $unitCount units in $($quantities.Count) quantities".PadRight($pad)
304304
Write-Host "`n`n"
305-
exit 0
305+
exit 0

UnitsNet/UnitDefinitions/ThermalResistance.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Name": "ThermalResistance",
33
"BaseUnit": "SquareMeterKelvinPerKilowatt",
44
"XmlDoc": "Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.",
@@ -11,7 +11,7 @@
1111
"Localization": [
1212
{
1313
"Culture": "en-US",
14-
"Abbreviations": [ "m²K/kW" ]
14+
"Abbreviations": [ "m²K/kW" ]
1515
}
1616
]
1717
},
@@ -23,7 +23,7 @@
2323
"Localization": [
2424
{
2525
"Culture": "en-US",
26-
"Abbreviations": [ "m²°C/W" ]
26+
"Abbreviations": [ "m²°C/W" ]
2727
}
2828
]
2929
},
@@ -35,7 +35,7 @@
3535
"Localization": [
3636
{
3737
"Culture": "en-US",
38-
"Abbreviations": [ "cm²K/W" ]
38+
"Abbreviations": [ "cm²K/W" ]
3939
}
4040
]
4141
},
@@ -47,7 +47,7 @@
4747
"Localization": [
4848
{
4949
"Culture": "en-US",
50-
"Abbreviations": [ "cm²Hr°C/kcal" ]
50+
"Abbreviations": [ "cm²Hr°C/kcal" ]
5151
}
5252
]
5353
},
@@ -59,7 +59,7 @@
5959
"Localization": [
6060
{
6161
"Culture": "en-US",
62-
"Abbreviations": [ "Hrft²°F/Btu" ]
62+
"Abbreviations": [ "Hrft²°F/Btu" ]
6363
}
6464
]
6565
}

0 commit comments

Comments
 (0)