Examples of Encoding


Examples of org.apache.pdfbox.pdmodel.font.encoding.Encoding

                }
            }
            else if (encoding instanceof COSDictionary)
            {
                COSDictionary encodingDict = (COSDictionary)encoding;
                Encoding builtIn = null;
                if (!encodingDict.containsKey(COSName.BASE_ENCODING) && isSymbolic())
                {
                    builtIn = readEncodingFromFont();
                }
                Boolean symbolic = getSymbolicFlag();
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.encoding.Encoding

        stream.getStream().setInt(COSName.LENGTH1, stream.getByteArray().length); // todo: wrong?
        stream.addCompression();

        // only support winansi encoding right now, should really
        // just use Identity-H with unicode mapping
        Encoding encoding = new WinAnsiEncoding(); // fixme: read encoding from TTF

        this.fontEncoding = encoding;
        dict.setItem(COSName.ENCODING, encoding.getCOSObject());

        // as the stream was close within the PDStream constructor, we have to recreate it
        InputStream stream2 = null;
        PDFontDescriptor fd;
        try
View Full Code Here

Examples of org.axsl.ps.Encoding

        /* If none already exists, create one. */
        if (sf != null) {
            /* We don't care about encodings for SystemFonts. */
            fontUse = new FontUse4a(this, rfd, null);
        } else {
            final Encoding encoding = findEncoding(rfd, codePoint);
            if (encoding == null) {
                /* We can't encode this character.
                 * Return null so that the upstream font selection routines can
                 * try another font family. */
                return null;
View Full Code Here

Examples of org.jcodings.Encoding

        return s;
    }
   
    private ByteList inspectIntoByteList(boolean ignoreKCode) {
        Ruby runtime = getRuntime();
        Encoding enc = runtime.getKCode().getEncoding();
        final int length = value.length();
        ByteList sb = new ByteList(length + 2 + length / 100);

        sb.append('\"');

        for (int i = 0; i < length; i++) {
            int c = value.get(i) & 0xFF;
           
            if (!ignoreKCode) {
                int seqLength = enc.length((byte)c);
               
                if (seqLength > 1 && (i + seqLength -1 < length)) {
                    // don't escape multi-byte characters, leave them as bytes
                    sb.append(value, i, seqLength);
                    i += seqLength - 1;
View Full Code Here

Examples of org.jcodings.Encoding

        byte[]bytes = value.bytes;
        final Matcher matcher = regex.matcher(bytes, begin, range);
       
        boolean lastNull = false;
        RubyArray result = runtime.newArray();
        final Encoding enc = regex.getEncoding();
       
        if (regex.numberOfCaptures() == 0) { // shorter path, no captures defined, no region will be returned
            while ((end = matcher.search(start, range, Option.NONE)) >= 0) {
                if (start == end + begin && matcher.getBegin() == matcher.getEnd()) {
                    if (value.realSize == 0) {
                        result.append(newEmptyString(runtime, getMetaClass()));
                        break;
                    } else if (lastNull) {
                        result.append(substr(runtime, beg, enc.length(bytes, begin + beg, range)));
                        beg = start - begin;
                    } else {
                        if (start == range) {
                            start++;
                        } else {
                            start += enc.length(bytes, start, range);
                        }
                        lastNull = true;
                        continue;
                    }
                } else {
                    result.append(substr(beg, end - beg));
                    beg = matcher.getEnd();
                    start = begin + matcher.getEnd();
                }
                lastNull = false;
                if (limit && lim <= ++i) break;
            }
        } else {
            while ((end = matcher.search(start, range, Option.NONE)) >= 0) {
                final Region region = matcher.getRegion();
                if (start == end + begin && region.beg[0] == region.end[0]) {
                    if (value.realSize == 0) {                       
                        result.append(newEmptyString(runtime, getMetaClass()));
                        break;
                    } else if (lastNull) {
                        result.append(substr(beg, enc.length(bytes, begin + beg, range)));
                        beg = start - begin;
                    } else {
                        if (start == range) {
                            start++;
                        } else {
                            start += enc.length(bytes, start, range);
                        }
                        lastNull = true;
                        continue;
                    }                   
                } else {
View Full Code Here

Examples of org.jcodings.Encoding

    private final void rb_reg_expr_str(StringBuilder sb, byte[] s, int start, int len) {
        int p,pend;
        boolean need_escape = false;
        p = start;
        pend = start+len;
        Encoding enc = kcode.getEncoding();
        while (p < pend) {
            if (s[p] == '/' ||
                    (!(' ' == s[p] || (!Character.isWhitespace(s[p]) &&
                                       !Character.isISOControl(s[p]))) &&
                    enc.length(s, p, pend) == 1)) {
                need_escape = true;
                break;
            }
            p += enc.length(s, p, pend);
        }
        if (!need_escape) {
            sb.append(new ByteList(s,start,len,false).toString());
        } else {
            p = 0;
            while (p < pend) {
                if (s[p] == '\\') {
                    int n = enc.length(s, p + 1, pend) + 1;
                    sb.append(new ByteList(s,p,n,false).toString());
                    p += n;
                    continue;
                } else if (s[p] == '/') {
                    sb.append("\\/");
                } else if (enc.length(s, p, pend) != 1) {
                    sb.append(new ByteList(s, p, enc.length(s, p, pend), false).toString());
                    p += enc.length(s, p, pend);
                    continue;
                } else if ((' ' == s[p] || (!Character.isWhitespace(s[p]) &&
                                           !Character.isISOControl(s[p])))) {
                    sb.append((char)(s[p]&0xFF));
                } else if (!Character.isWhitespace((char)(s[p]&0xFF))) {
View Full Code Here

Examples of org.jcodings.Encoding

        int no = -1;
        ByteList bs = str.getByteList();
        ByteList srcbs = src.getByteList();
        int e = bs.realSize;
        RubyString val = null;
        Encoding enc = kcode.getEncoding();

        int beg, end;
        while (s < e) {
            int ss = s;
            int c = bs.charAt(s);
            int l = enc.length(bs.bytes, bs.begin + s++, bs.begin + e);
            if (l != 1) {
                s += l - 1;
                continue;
            }
            if (c != '\\' || s == e) continue;
View Full Code Here

Examples of org.jcodings.Encoding

    private final void rb_reg_expr_str(RubyString ss, int s, int len) {
        int p = s;
        int pend = p + len;
        boolean need_escape = false;
        Encoding enc = kcode.getEncoding();
        while (p < pend) {
            if (str.bytes[p] == '/' || (!enc.isPrint(str.bytes[p] & 0xff) && enc.length(str.bytes, p, pend) == 1)) {
                need_escape = true;
                break;
            }
            p += enc.length(str.bytes, p, pend);
        }
        if (!need_escape) {
            ss.cat(str.bytes, s, len);
        } else {
            p = s;
            while (p<pend) {
                if (str.bytes[p] == '\\') {
                    int n = enc.length(str.bytes, p + 1, pend) + 1;
                    ss.cat(str.bytes, p, n);
                    p += n;
                    continue;
                } else if (str.bytes[p] == '/') {
                    ss.cat((byte)'\\');
                    ss.cat(str.bytes, p, 1);
                } else if (enc.length(str.bytes, p, pend) != 1) {
                    ss.cat(str.bytes, p, enc.length(str.bytes, p, pend));
                    p += enc.length(str.bytes, p, pend);
                    continue;
                } else if (enc.isPrint(str.bytes[p] & 0xff)) {
                    ss.cat(str.bytes,p,1);
                } else if (!enc.isSpace(str.bytes[p] & 0xff)) {
                    ss.cat(ByteList.create(Integer.toString(str.bytes[p] & 0377, 8)));
                } else {
                    ss.cat(str.bytes, p, 1);
                }
                p++;
View Full Code Here

Examples of org.jcodings.Encoding

    public static ByteList quote(ByteList str, KCode kcode) {
        ByteList bs = str;
        int tix = 0;
        int s = bs.begin;
        int send = s + bs.length();
        Encoding enc = kcode.getEncoding();
        meta_found: do {
            for(; s < send; s++) {
                int c = bs.bytes[s] & 0xff;
                int l = enc.length(bs.bytes, s, send);
                if (l != 1) {
                    int n = l;
                    while (n-- > 0 && s < send) {
                        s++;
                    }
                    s--;
                    continue;
                }
                switch (c) {
                case '[': case ']': case '{': case '}':
                case '(': case ')': case '|': case '-':
                case '*': case '.': case '\\':
                case '?': case '+': case '^': case '$':
                case ' ': case '#':
                case '\t': case '\f': case '\n': case '\r':
                    break meta_found;
                }
            }
            return bs;
        } while (false);
        ByteList b1 = new ByteList(send*2);
        System.arraycopy(bs.bytes,bs.begin,b1.bytes,b1.begin,s-bs.begin);
        tix += (s-bs.begin);

        for(; s<send; s++) {
            int c = bs.bytes[s] & 0xff;
            int l = enc.length(bs.bytes, s, send);
            if (l != 1) {
                int n = l;
                while (n-- > 0 && s < send) {
                    b1.bytes[tix++] = bs.bytes[s++];
                }
View Full Code Here

Examples of org.jcodings.Encoding

        Ruby runtime = context.getRuntime();
        ByteList value = str.getByteList();
       
        if (pos >= value.realSize) return runtime.getNil();

        Encoding enc = runtime.getKCode().getEncoding();
       
        int len;
        if (enc.isSingleByte()) {
            len = 1;
        } else {
            len = enc.length(value.bytes, value.begin + pos, value.begin + value.realSize);
        }
       
        if (pos + len > value.realSize) len = value.realSize - pos;
        lastPos = pos;
        pos += len;
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.