angularsen / UnitsNet

Makes life working with units of measurement just a little bit better.
https://www.nuget.org/packages/UnitsNet/
MIT No Attribution
2.19k stars 380 forks source link

UnitParser.Default.Parse("m3", typeof(VolumeUnit)) not working #855

Closed jstevense-vbe closed 3 years ago

jstevense-vbe commented 3 years ago

Is your feature request related to a problem? Please describe. UnitParser.Default.Parse("m3", typeof(VolumeUnit)) is throwing an exception because only the superscript version is checked.

Describe the solution you'd like Make the UnitParser more flexible by not only checking for m³ but also m3

Describe alternatives you've considered Parsing the unit string myself.

angularsen commented 3 years ago

Hi, this would be a great addition. We already support similar schemes for m^3: https://github.com/angularsen/UnitsNet/blob/master/UnitsNet/CustomCode/UnitParser.cs#L103-L132

One pitfall I'm a bit worried about is whether it could conflict with some other unit's abbreviation, but I can't really think of any such cases.

Would you be interested in attempting a pull request? I'm happy to assist.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.