コード例 #1
0
ファイル: interp_locale.py プロジェクト: njues/Sypy
                  w(rffi.charp2str(lp.c_positive_sign)))
    space.setitem(w_result, w("negative_sign"),
                  w(rffi.charp2str(lp.c_negative_sign)))
    space.setitem(w_result, w("int_frac_digits"), w(lp.c_int_frac_digits))
    space.setitem(w_result, w("frac_digits"), w(lp.c_frac_digits))
    space.setitem(w_result, w("p_cs_precedes"), w(lp.c_p_cs_precedes))
    space.setitem(w_result, w("p_sep_by_space"), w(lp.c_p_sep_by_space))
    space.setitem(w_result, w("n_cs_precedes"), w(lp.c_n_cs_precedes))
    space.setitem(w_result, w("n_sep_by_space"), w(lp.c_n_sep_by_space))
    space.setitem(w_result, w("p_sign_posn"), w(lp.c_p_sign_posn))
    space.setitem(w_result, w("n_sign_posn"), w(lp.c_n_sign_posn))

    return w_result


_strcoll = rlocale.external('strcoll', [rffi.CCHARP, rffi.CCHARP], rffi.INT)
_wcscoll = rlocale.external('wcscoll', [rffi.CWCHARP, rffi.CWCHARP], rffi.INT)


def strcoll(space, w_s1, w_s2):
    "string,string -> int. Compares two strings according to the locale."

    if space.is_true(space.isinstance(w_s1, space.w_str)) and \
       space.is_true(space.isinstance(w_s2, space.w_str)):

        s1, s2 = space.str_w(w_s1), space.str_w(w_s2)
        s1_c = rffi.str2charp(s1)
        s2_c = rffi.str2charp(s2)
        try:
            return space.wrap(_strcoll(s1_c, s2_c))
        finally:
コード例 #2
0
ファイル: interp_locale.py プロジェクト: Debug-Orz/Sypy
    space.setitem(w_result, w("p_cs_precedes"),
                  w(lp.c_p_cs_precedes))
    space.setitem(w_result, w("p_sep_by_space"),
                  w(lp.c_p_sep_by_space))
    space.setitem(w_result, w("n_cs_precedes"),
                  w(lp.c_n_cs_precedes))
    space.setitem(w_result, w("n_sep_by_space"),
                  w(lp.c_n_sep_by_space))
    space.setitem(w_result, w("p_sign_posn"),
                  w(lp.c_p_sign_posn))
    space.setitem(w_result, w("n_sign_posn"),
                  w(lp.c_n_sign_posn))

    return w_result

_strcoll = rlocale.external('strcoll', [rffi.CCHARP, rffi.CCHARP], rffi.INT)
_wcscoll = rlocale.external('wcscoll', [rffi.CWCHARP, rffi.CWCHARP], rffi.INT)

def strcoll(space, w_s1, w_s2):
    "string,string -> int. Compares two strings according to the locale."

    if space.is_true(space.isinstance(w_s1, space.w_str)) and \
       space.is_true(space.isinstance(w_s2, space.w_str)):

        s1, s2 = space.str_w(w_s1), space.str_w(w_s2)
        s1_c = rffi.str2charp(s1)
        s2_c = rffi.str2charp(s2)
        try:
            return space.wrap(_strcoll(s1_c, s2_c))
        finally:
            rffi.free_charp(s1_c)
コード例 #3
0
ファイル: test_rlocale.py プロジェクト: njues/Sypy
def test_libintl():
    if sys.platform != "darwin" or not sys.platform.startswith("linux"):
        py.test.skip("there is (maybe) no libintl here")
    _gettext = external('gettext', [rffi.CCHARP], rffi.CCHARP)
    res = _gettext("1234")
    assert rffi.charp2str(res) == "1234"