Skip to content

Commit

Permalink
Ensure locale invariant number formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbrooks committed Oct 18, 2024
1 parent c8c391e commit ae2d4ec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.jzbrooks.vgo.core.graphic.command.VerticalLineTo
import com.jzbrooks.vgo.core.util.math.Point
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import kotlin.math.sign

class ScalableVectorGraphicCommandPrinter(
Expand All @@ -28,6 +29,10 @@ class ScalableVectorGraphicCommandPrinter(
isGroupingUsed = false
roundingMode = RoundingMode.HALF_UP
minimumIntegerDigits = 0
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun print(command: Command): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.w3c.dom.Document
import java.io.OutputStream
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.util.Collections.emptySet
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.OutputKeys
Expand All @@ -31,6 +32,10 @@ class ScalableVectorGraphicWriter(
minimumIntegerDigits = 0
isDecimalSeparatorAlwaysShown = false
roundingMode = RoundingMode.HALF_UP
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun write(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.jzbrooks.vgo.core.graphic.command.VerticalLineTo
import com.jzbrooks.vgo.core.util.math.Point
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import kotlin.math.sign

class VectorDrawableCommandPrinter(
Expand All @@ -27,6 +28,10 @@ class VectorDrawableCommandPrinter(
isDecimalSeparatorAlwaysShown = false
isGroupingUsed = false
roundingMode = RoundingMode.HALF_UP
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun print(command: Command): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.w3c.dom.Document
import java.io.OutputStream
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.util.Collections.emptySet
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.OutputKeys
Expand All @@ -33,6 +34,10 @@ class VectorDrawableWriter(
minimumIntegerDigits = 0
isDecimalSeparatorAlwaysShown = false
roundingMode = RoundingMode.HALF_UP
decimalFormatSymbols =
DecimalFormatSymbols().apply {
decimalSeparator = '.'
}
}

override fun write(
Expand Down

0 comments on commit ae2d4ec

Please sign in to comment.