static jlong NativeCollation_openCollator(JNIEnv* env, jclass, jstring localeName) {
    ScopedUtfChars localeChars(env, localeName);
    if (localeChars.c_str() == NULL) {
        return 0;
    }
    UErrorCode status = U_ZERO_ERROR;
    UCollator* c = ucol_open(localeChars.c_str(), &status);
    maybeThrowIcuException(env, "ucol_open", status);
    return static_cast<jlong>(reinterpret_cast<uintptr_t>(c));
}
Exemplo n.º 2
0
static jint NativeCollation_openCollator(JNIEnv* env, jclass, jstring localeName) {
    ScopedUtfChars localeChars(env, localeName);
    if (localeChars.c_str() == NULL) {
        return 0;
    }
    UErrorCode status = U_ZERO_ERROR;
    UCollator* c = ucol_open(localeChars.c_str(), &status);
    icu4jni_error(env, status);
    return static_cast<jint>(reinterpret_cast<uintptr_t>(c));
}
Exemplo n.º 3
0
static jint getIterator(JNIEnv* env, jstring locale, UBreakIteratorType type) {
    UErrorCode status = U_ZERO_ERROR;
    ScopedUtfChars localeChars(env, locale);
    if (localeChars.c_str() == NULL) {
        return 0;
    }
    UBreakIterator* it = ubrk_open(type, localeChars.c_str(), NULL, 0, &status);
    icu4jni_error(env, status);
    return reinterpret_cast<uintptr_t>(it);
}
Exemplo n.º 4
0
static jstring getIntCurrencyCode(JNIEnv* env, jstring locale) {
    ScopedUtfChars localeChars(env, locale);

    // Extract the 2-character country name.
    if (strlen(localeChars.c_str()) < 5) {
        return NULL;
    }
    if (localeChars[3] < 'A' || localeChars[3] > 'Z' || localeChars[4] < 'A' || localeChars[4] > 'Z') {
        return NULL;
    }

    char country[3] = { localeChars[3], localeChars[4], 0 };
    return ICU_getCurrencyCodeNative(env, NULL, env->NewStringUTF(country));
}