def get_const_ptr_for_unicode(s): from pypy.rpython.annlowlevel import llunicode if not we_are_translated(): try: return _const_ptr_for_unicode[s] except KeyError: pass if isinstance(s, str): s = unicode(s) result = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, llunicode(s))) if not we_are_translated(): _const_ptr_for_unicode[s] = result return result
def f(arg): s = llunicode(hlunicode(arg)) return len(s.chars)
def test_llunicode(self): s = llunicode(u"abc") assert len(s.chars) == 3 assert s.chars[0] == u"a" assert s.chars[1] == u"b" assert s.chars[2] == u"c"