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

Fix ToSvgString #525

Merged
merged 2 commits into from Jul 24, 2019
Merged

Fix ToSvgString #525

merged 2 commits into from Jul 24, 2019

Conversation

wieslawsoltes
Copy link
Contributor

What does this implement/fix? Explain your changes.

The ToSvgString method used current culture which produces invalid path data on some culture (uses , instead of . for separator.

@@ -14,7 +14,7 @@ public static class PointFExtensions
{
public static string ToSvgString(this PointF p)
{
return p.X.ToString() + " " + p.Y.ToString();
return p.X.ToString(CultureInfo.InvariantCulture) + " " + p.Y.ToString(CultureInfo.InvariantCulture);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - not the first time I see such an error!

@mrbean-bremen mrbean-bremen merged commit a651554 into svg-net:master Jul 24, 2019
@wieslawsoltes wieslawsoltes deleted the FixToSvgString branch July 24, 2019 18:09
@H1Gdev
Copy link
Contributor

H1Gdev commented Jul 24, 2019

@wieslawsoltes
@mrbean-bremen

https://github.com/vvvv/SVG/blob/a6515547b5e49ee6844611d0423155c24199d434/Source/Paths/SvgPathBuilder.cs#L485-L496

I don't know which of way is good, but I think that it is better to unify either.

@wieslawsoltes
Copy link
Contributor Author

Seems like SvgPathBuilder does not need to change culture after my latest PRs.

@mrbean-bremen
Copy link
Member

I would prefer to always use the explicit invariant culture for float.ToString() and float.TryParse(), where the representation is fixed (as it is in SVG) - this is less error-prone IMHO.
So I like it the way @wieslawsoltes has done this, and I agree that the code in SvgPathBuilder can probably be removed (maybe can be added to the other PR).

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

Successfully merging this pull request may close these issues.

None yet

3 participants