当前位置: 首页>>代码示例>>Java>>正文


Java Surrogate.high方法代码示例

本文整理汇总了Java中sun.nio.cs.Surrogate.high方法的典型用法代码示例。如果您正苦于以下问题:Java Surrogate.high方法的具体用法?Java Surrogate.high怎么用?Java Surrogate.high使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.nio.cs.Surrogate的用法示例。


在下文中一共展示了Surrogate.high方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decode

import sun.nio.cs.Surrogate; //导入方法依赖的package包/类
public int decode(byte[] src, int sp, int len, char[] dst) {
    int dp = 0;
    int sl = sp + len;
    char repl = replacement().charAt(0);
    while (sp < sl) {
        int b1 = src[sp++] & 0xff;
        char c = decodeSingle(b1);
        if (c == UNMAPPABLE_DECODING) {
            if (sl == sp) {
                c = repl;
            } else {
                int b2 = src[sp++] & 0xff;
                if (b2 < b2Min || b2 > b2Max) {
                    c = repl;
                } else if ((c = decodeDouble(b1, b2)) == UNMAPPABLE_DECODING) {
                    c = decodeDoubleEx(b1, b2);     //supp
                    if (c == UNMAPPABLE_DECODING) {
                        c = decodeBig5(b1, b2);     //big5
                        if (c == UNMAPPABLE_DECODING)
                            c = repl;
                    } else {
                        // supplementary character in u+2xxxx area
                        dst[dp++] = Surrogate.high(0x20000 + c);
                        dst[dp++] = Surrogate.low(0x20000 + c);
                        continue;
                    }
                }
            }
        }
        dst[dp++] = c;
    }
    return dp;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:HKSCS.java

示例2: decodeArrayLoop

import sun.nio.cs.Surrogate; //导入方法依赖的package包/类
protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
    byte[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();

    char[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();

    try {
        while (sp < sl) {
            int b1 = sa[sp] & 0xff;
            char c = decodeSingle(b1);
            int inSize = 1, outSize = 1;
            char[] cc = null;
            if (c == UNMAPPABLE_DECODING) {
                if (sl - sp < 2)
                    return CoderResult.UNDERFLOW;
                int b2 = sa[sp + 1] & 0xff;
                inSize++;
                if (b2 < b2Min || b2 > b2Max)
                    return CoderResult.unmappableForLength(2);
                c = decodeDouble(b1, b2);           //bmp
                if (c == UNMAPPABLE_DECODING) {
                    c = decodeDoubleEx(b1, b2);     //supp
                    if (c == UNMAPPABLE_DECODING) {
                        c = decodeBig5(b1, b2);     //big5
                        if (c == UNMAPPABLE_DECODING)
                            return CoderResult.unmappableForLength(2);
                    } else {
                        // supplementary character in u+2xxxx area
                        outSize = 2;
                    }
                }
            }
            if (dl - dp < outSize)
                return CoderResult.OVERFLOW;
            if (outSize == 2) {
                // supplementary characters
                da[dp++] = Surrogate.high(0x20000 + c);
                da[dp++] = Surrogate.low(0x20000 + c);
            } else {
                da[dp++] = c;
            }
            sp += inSize;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(sp - src.arrayOffset());
        dst.position(dp - dst.arrayOffset());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:HKSCS.java


注:本文中的sun.nio.cs.Surrogate.high方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。