我真正想要做的是使用strftime("%x")
以正确的顺序格式化日期。在大多数平台上拨打setlocale("")
就足够了。在Android上,我一直在收到!@#$美国的日期。Android NDK支持语言环境吗?
那么,Android不支持语言环境吗?
我真正想要做的是使用strftime("%x")
以正确的顺序格式化日期。在大多数平台上拨打setlocale("")
就足够了。在Android上,我一直在收到!@#$美国的日期。Android NDK支持语言环境吗?
那么,Android不支持语言环境吗?
根据this答案是
号没有在C库/从本机代码的语言环境不支持,这是故意的。 Elliot指出,你唯一的希望就是使用JNI来获得相关的值。
编号setlocale()
和strftime()
在Android NDK中不起作用,除非en_US布局是您想要的。
我从Java的部分由当地语言:
pLocaleData->pLocaleLanguage = new Locale("en").getDefault().getLanguage();
而ANSI C localeconv()
中的Android NDK不起作用:
struct lconv *localeconv(void);
也越来越的用户名的标准的Unix方式,在Android中不起作用。
char *p = getenv("USER");
所以你需要使用Java端,以获得区域设置信息。
String LocaleCountry = new Locale("en").getDefault().getCountry();
String LocaleLanguage = new Locale("en").getDefault().getLanguage();
String LocaleCurrency = new DecimalFormatSymbols().getCurrency().toString();
String LocaleShortDateTimePattern =new SimpleDateFormat().toPattern();
char LocaleDecimalSeparator = new DecimalFormatSymbols().getDecimalSeparator();
char LocaleThousandSeparator = new DecimalFormatSymbols().getGroupingSeparator();
String LocaleThousandGrouping =
String.format("%d;0", new DecimalFormat().getMaximumFractionDigits());
String LocaleNegativePrefix = new DecimalFormat().getNegativePrefix();
String LocaleNegativeSuffix =new DecimalFormat().getNegativeSuffix();
String Operator = Utils.getQwnername(context);
看起来是一个主要的Android Java/Android实现(电话)在千位分隔符问题上的错误。该=新的DecimalFormatSymbols()。getGroupingSeparator();为ISO标准/德国 - 瑞典等(非美国)千分组生成0xa0(ISO/IEC 8859-1 NBSP,不是UTF8)而不是0x20空格分隔符。这会导致Java代码在使用时崩溃。在读取0xa0 = new DecimalFormatSymbols()后,必须在Java代码中将0xa0更改为0x20。getGroupingSeparator();另见http://stackoverflow.com/questions/32374466/replace-grouping-separator-of-decimalformat-in-formatted-value。 –