diff options
author | Jerome Gaillard <jgaillard@google.com> | 2020-09-14 15:20:23 +0100 |
---|---|---|
committer | Jerome Gaillard <jgaillard@google.com> | 2020-09-15 12:20:02 +0100 |
commit | d4c2ba1d2ef800e7e84a29487c7f60c69dc3ee95 (patch) | |
tree | 87782e47cd2ea7aee4f61008e9fe8a8abe2e980e /core/jni/LayoutlibLoader.cpp | |
parent | 1570626a6c506ead74c51ebac23c55a7319d3681 (diff) |
Use English locale for number format in layoutlib
Vector drawable path parsing relies on the locale numeric format using
'.' as the decimal point. This sets the locale numeric format to
English, in case the host locale breaks this assumption.
Bug: 167164437
Test: checked manually
Change-Id: Iad43f29a1c2b00039f5056f6244b9cf46f89b68c
Diffstat (limited to 'core/jni/LayoutlibLoader.cpp')
-rw-r--r-- | core/jni/LayoutlibLoader.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/jni/LayoutlibLoader.cpp b/core/jni/LayoutlibLoader.cpp index 77c1a1097240..4e50f87c086b 100644 --- a/core/jni/LayoutlibLoader.cpp +++ b/core/jni/LayoutlibLoader.cpp @@ -17,9 +17,9 @@ #include "jni.h" #include "core_jni_helpers.h" -#include <sstream> -#include <iostream> #include <unicode/putil.h> +#include <clocale> +#include <sstream> #include <unordered_map> #include <vector> @@ -198,6 +198,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) { u_setDataDirectory(path); env->ReleaseStringUTFChars(stringPath, path); + // Use English locale for number format to ensure correct parsing of floats when using strtof + setlocale(LC_NUMERIC, "en_US.UTF-8"); return JNI_VERSION_1_6; } |