Examples of PyUnicode


Examples of org.python.core.PyUnicode

    public static PyTuple lookup(String encoding) {
        return codecs.lookup(encoding);
    }

    private static PyTuple decode_tuple(String s, int len) {
        return new PyTuple(new PyObject[] { new PyUnicode(s), Py.newInteger(len) });
    }
View Full Code Here

Examples of org.python.core.PyUnicode

        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyUnicode)
                return (PyUnicode) res;
            if (res instanceof PyString)
                return new PyUnicode((PyString) res);
            throw Py.TypeError("__unicode__" + " should return a " + "unicode");
        }
        return super.__unicode__();
    }
View Full Code Here

Examples of org.python.core.PyUnicode

        if (impl != null) {
            PyObject res = impl.__get__(this, self_type).__call__();
            if (res instanceof PyUnicode)
                return (PyUnicode) res;
            if (res instanceof PyString)
                return new PyUnicode((PyString) res);
            throw Py.TypeError("__unicode__" + " should return a " + "unicode");
        }
        return super.__unicode__();
    }
View Full Code Here

Examples of org.python.core.PyUnicode

    /**
     * Motivated by a NPE reported on http://bugs.jython.org/issue1174.
     */
    public void testBasicEval() throws Exception {
        PyDictionary test = new PyDictionary();
        test.__setitem__(new PyUnicode("one"), new PyUnicode("two"));
        PythonInterpreter.initialize(System.getProperties(), null, new String[] {});
        PythonInterpreter interp = new PythonInterpreter();
        PyObject pyo = interp.eval("{u'one': u'two'}");
        assertEquals(test, pyo);
    }
View Full Code Here

Examples of org.python.core.PyUnicode

        final private void load_unicode() {
            String line = file.readlineNoNl();
            String value = codecs.PyUnicode_DecodeRawUnicodeEscape(line,
                                                                   "strict");
            push(new PyUnicode(value));
        }
View Full Code Here

Examples of org.python.core.PyUnicode

        }

        final private void load_binunicode() {
            int len = read_binint();
            String line = file.read(len);
            push(new PyUnicode(codecs.PyUnicode_DecodeUTF8(line, "strict")));
        }
View Full Code Here

Examples of org.python.core.PyUnicode

                ustring = true;
            }
            sb.append(sp.getString());
        }
        if (ustring) {
            return new PyUnicode(sb.toString());
        }
        return new PyString(sb.toString());
    }
View Full Code Here

Examples of org.python.core.PyUnicode

        // string is properly decoded according to the source encoding
        // XXX: No need to re-encode when the encoding is iso-8859-1, but ParserFacade
        // needs to normalize the encoding name
        if (!ustring && encoding != null) {
            // str with a specified encoding: first re-encode back out
            string = new PyUnicode(string.substring(start, end)).encode(encoding);
            if (!raw) {
                // Handle escapes in non-raw strs
                string = PyString.decode_UnicodeEscape(string, 0, string.length(), "strict",
                                                       ustring);
            }
View Full Code Here

Examples of org.python.core.PyUnicode

    public static PyObject charmap_build(PyUnicode map) {
        return EncodingMap.buildEncodingMap(map);
    }

    private static PyTuple decode_tuple(String s, int len) {
        return new PyTuple(new PyUnicode(s), Py.newInteger(len));
    }
View Full Code Here

Examples of org.python.core.PyUnicode

            } else {
                // wrong return value
                throw Py.TypeError("character mapping must return integer, None or unicode");
            }
        }
        return new PyUnicode(buf.toString());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.