c_src/ustring.c
ERL_NIF_TERM ustring_casecmp(ErlNifEnv* env, int argc,
                             const ERL_NIF_TERM argv[]) {
    ErlNifBinary stra, strb;
    int32_t result;
    UErrorCode ec = U_ZERO_ERROR;

    if (!enif_inspect_binary(env, argv[0], &stra))
        return enif_make_badarg(env);
    if (!enif_inspect_binary(env, argv[1], &strb))
        return enif_make_badarg(env);

    result = u_strCaseCompare((UChar*)stra.data, stra.size/2,
                              (UChar*)strb.data, strb.size/2,
                              U_FOLD_CASE_DEFAULT, &ec);

    if(U_FAILURE(ec))
        return error_tuple(env, u_errorName(ec));

    return enif_make_int(env, result);
}
/*
 * Compare two strings for case-insensitive equality. Non-equality
 * sort ordering is done in code unit order.
 * Inputs:
 *   0: binary(), first string to be compared
 *   1: binary(), second string to be compared
 * Outputs (one of):
 *   integer(), 0 if equal,
 *              <0 if argv[0] < argv[1],
 *              >0 if argv[0] > argv[1]
 *   {'error', Reason::string()}, something went wrong
 */
Compare two strings for case-insensitive equality. Non-equality
sort ordering is done in code unit order.
Compare two strings for case - insensitive equality . Non - equality sort ordering is done in code unit order .
ERL_NIF_TERM ustring_casecmp(ErlNifEnv* env, int argc,
                             const ERL_NIF_TERM argv[]) {
    ErlNifBinary stra, strb;
    int32_t result;
    UErrorCode ec = U_ZERO_ERROR;
    if (!enif_inspect_binary(env, argv[0], &stra))
        return enif_make_badarg(env);
    if (!enif_inspect_binary(env, argv[1], &strb))
        return enif_make_badarg(env);
    result = u_strCaseCompare((UChar*)stra.data, stra.size/2,
                              (UChar*)strb.data, strb.size/2,
                              U_FOLD_CASE_DEFAULT, &ec);
    if(U_FAILURE(ec))
        return error_tuple(env, u_errorName(ec));
    return enif_make_int(env, result);
}
ERL_NIF_TERM ustring_casecmp ( ErlNifEnv * env , int argc , const ERL_NIF_TERM argv [ ] ) { ErlNifBinary stra , strb ; int32_t result ; UErrorCode ec = U_ZERO_ERROR ; if ( ! enif_inspect_binary ( env , argv [ 0 ] , & stra ) ) return enif_make_badarg ( env ) ; if ( ! enif_inspect_binary ( env , argv [ 1 ] , & strb ) ) return enif_make_badarg ( env ) ; result = u_strCaseCompare ( ( UChar * ) stra . data , stra . size / 2 , ( UChar * ) strb . data , strb . size / 2 , U_FOLD_CASE_DEFAULT , & ec ) ; if ( U_FAILURE ( ec ) ) return error_tuple ( env , u_errorName ( ec ) ) ; return enif_make_int ( env , result ) ; }
Compare two strings for case-insensitive equality.
Compare two strings for case - insensitive equality .