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

java: format strings containing integers in ROOT locale. #41

Merged
merged 1 commit into from
Mar 13, 2022

Conversation

DentonGentry
Copy link
Contributor

@DentonGentry DentonGentry commented Mar 13, 2022

We use strings to pass structured data from the JVM to Go.
In a locale using Indian-Arabic numerals: ۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹
the Java code will format decimal strings using Indian-Arabic
glyphs.

Go doesn't get a locale set automatically by the Android
runtime, so it always parses strings in a default en-US
unable to parse "lo ١ ٦٥٥٣٦ true false true false false |": expected integer

Make the Java code format using the ROOT locale. These strings
are purely internal to pass between the two runtimes, they are
not shown to the user.

Fixes tailscale/tailscale#4156

Signed-off-by: Denton Gentry dgentry@tailscale.com

@DentonGentry
Copy link
Contributor Author

DentonGentry commented Mar 13, 2022

I don't have a phone with a Saudi Arabian or another similar locale available to try. This doesn't break the US locale, and should fix locales using Indian-Arabic numerals.

@bradfitz
Copy link
Member

Is this PR meant to be bumping versions of things and disabling vulkan? Seems unrelated

@DentonGentry
Copy link
Contributor Author

Created the branch from the wrong place.

Copy link
Member

@bradfitz bradfitz left a comment

Choose a reason for hiding this comment

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

I think you want Locale.ROOT, though, which is like locale "C" in C.

The root locale is the locale whose language, country, and variant are empty ("") strings. This is regarded as the base locale of all locales, and is used as the language/country neutral locale for the locale sensitive operations.

We use strings to pass structured data from the JVM to Go.
In a locale using Indian-Arabic numerals: ۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹
the Java code will format decimal strings using Indian-Arabic
glyphs.

Go doesn't get a locale set automatically by the Android
runtime, so it always parses strings in a default en-US
`unable to parse "lo ١ ٦٥٥٣٦ true false true false false |": expected integer`

Make the Java code format using the ROOT locale. These strings
are purely internal to pass between the two runtimes, they are
not shown to the user.

Fixes tailscale/tailscale#4156

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
@DentonGentry DentonGentry changed the title java: format strings containing integers in US locale. java: format strings containing integers in ROOT locale. Mar 13, 2022
@DentonGentry DentonGentry merged commit b0f1428 into main Mar 13, 2022
@DentonGentry DentonGentry deleted the digits branch March 13, 2022 03:47
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.

Android app fails in locales with Indian-Arabic numerals
2 participants