Skip to content

Commit

Permalink
Fix string formatting a float without explicit locale (#86)
Browse files Browse the repository at this point in the history
* Use explicit Locale.US in String.format,
* yrel is read back using toFloatOrNull(), which requires a decimal point.
  • Loading branch information
autumngray authored Oct 18, 2023
1 parent c44c719 commit 6fca390
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/com/starry/myne/epub/BookTextMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package com.starry.myne.epub

import org.jsoup.Jsoup
import java.util.Locale

object BookTextMapper {
// <img yrel="{float}"> {uri} </img>
Expand Down Expand Up @@ -62,7 +63,7 @@ object BookTextMapper {
}

private fun toXMLStringV1(): String {
return """<img src="$path" yrel="${"%.2f".format(yrel)}">"""
return """<img src="$path" yrel="${"%.2f".format(Locale.US, yrel)}">"""
}

/*
Expand Down

0 comments on commit 6fca390

Please sign in to comment.