-
Notifications
You must be signed in to change notification settings - Fork 397
Description
Setting up by mapping an abbreviation to an unit:
UnitSystem unitSystem = UnitSystem.GetCached("en-US"); unitSystem.MapUnitToAbbreviation(UnitsNet.Units.AccelerationUnit.MeterPerSecondSquared, "m2");
The then following works as expected, printing "MeterPerSecondSquared":
Console.WriteLine(unitSystem.Parse<UnitsNet.Units.AccelerationUnit>("m2").ToString());
But parsing from Acceleration , I expect "12 m/s²" but it throws exception
UnitsNetException: Error parsing string. The unit is not a recognized AccelerationUnit.
Console.WriteLine(Acceleration.Parse("12 m2").ToString());
It likely lies with the regular expression pattern in UnitParser.ParseUnit.
This is important for me because I am expecting to parse user-typed input. It is not reasonable for the user to enter the pretty input of m/s², but rather m/s^2 which has the same meaning.
I will fork and try to work it out.