extern "C" jstring Java_libcore_icu_ICU_getDisplayCountryNative(JNIEnv* env, jclass, jstring targetLocale, jstring locale) { Locale loc = getLocale(env, locale); Locale targetLoc = getLocale(env, targetLocale); UnicodeString str; targetLoc.getDisplayCountry(loc, str); return env->NewString(str.getBuffer(), str.length()); }
void formatErrorMessage(UErrorCode &realStatus, const UnicodeString& pattern, const Locale& theLocale, UErrorCode inStatus0, /* statusString 1 */ const Locale &inCountry2, double currency3, // these numbers are the message arguments. UnicodeString &result) { if(U_FAILURE(realStatus)) return; // you messed up UnicodeString errString1(u_errorName(inStatus0)); UnicodeString countryName2; inCountry2.getDisplayCountry(theLocale,countryName2); Formattable myArgs[] = { Formattable((int32_t)inStatus0), // inStatus0 {0} Formattable(errString1), // statusString1 {1} Formattable(countryName2), // inCountry2 {2} Formattable(currency3)// currency3 {3,number,currency} }; MessageFormat *fmt = new MessageFormat("MessageFormat's API is broken!!!!!!!!!!!",realStatus); fmt->setLocale(theLocale); fmt->applyPattern(pattern, realStatus); if (U_FAILURE(realStatus)) { delete fmt; return; } FieldPosition ignore = 0; fmt->format(myArgs,4,result,ignore,realStatus); delete fmt; }
static jstring getDisplayCountryNative(JNIEnv* env, jclass clazz, jstring targetLocale, jstring locale) { Locale loc = getLocale(env, locale); Locale targetLoc = getLocale(env, targetLocale); UnicodeString str; targetLoc.getDisplayCountry(loc, str); return env->NewString(str.getBuffer(), str.length()); }
static jstring getDisplayCountryNative(JNIEnv* env, jclass clazz, jstring targetLocale, jstring locale) { // LOGI("ENTER getDisplayCountryNative"); UErrorCode status = U_ZERO_ERROR; Locale loc = getLocale(env, locale); Locale targetLoc = getLocale(env, targetLocale); UnicodeString string; targetLoc.getDisplayCountry(loc, string); jstring result = getJStringFromUnicodeString(env, string); return result; }