Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Everything returns 0 with ByteSize.Parse or ByteSize.TryParse #17

Closed
erwinkramer opened this issue Jul 22, 2016 · 5 comments
Closed

Everything returns 0 with ByteSize.Parse or ByteSize.TryParse #17

erwinkramer opened this issue Jul 22, 2016 · 5 comments

Comments

@erwinkramer
Copy link

erwinkramer commented Jul 22, 2016

Installed the latest version from NuGet. Using Visual Studio 2015 targeting .NET 4.5 and made this code:

var m = ByteSize.Parse("1.55B").MegaBytes;
var n = ByteSize.Parse("24.44 gB").MegaBytes;

ByteSize output;
ByteSize.TryParse("24.44 gB", out output);
var o = output.MegaBytes;

All 3 variables (m,n,o) result in 0. Not sure what's the matter here.

The following example does work as intended:
var monthlyUsage = ByteSize.FromGigaBytes(10);

@omar
Copy link
Owner

omar commented Jul 22, 2016

Thanks for filing the issue.

What culture/locale are you running in?

@erwinkramer
Copy link
Author

That seems to be the problem Omar,

My locale is '{nl-NL}'

If i set it manually, on the thread, to en-US like below it works just fine:
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");

It should be working for {nl-NL} too, right?

@omar
Copy link
Owner

omar commented Jul 23, 2016

Yes, it should work in nl-NL.

The nl-NL culture NumberDecimalSeparator is a , so the code is looking for that. It's not looking for the NumberGroupSeparator per locale. I believe that's the issue. See https://github.com/omar/ByteSize/blob/master/src/ByteSizeLib/ByteSize.cs#L326

My parallels isn't working (I'm on a Mac). I need to figure out how to get ByteSize setup for dotnet core and then I can fix this.

@omar omar closed this as completed in 6164a48 Jul 23, 2016
@omar
Copy link
Owner

omar commented Jul 23, 2016

@erwinkramer, I just released v1.2.1 on NuGet with the fix. Thanks for reporting this.

@erwinkramer
Copy link
Author

@omar Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants