⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sapchartonucbyteconverter.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        case 2: // '\002'
                            out[outIndex++] = charLength2ToByte[++tabIndex];
                            out[outIndex++] = charLength2ToByte[++tabIndex];
                            break;

                        case 3: // '\003'
                            tabIndex = ((charLength2ToByte[tabIndex + 1] & 0xff) << 8 | charLength2ToByte[tabIndex + 2] & 0xff) * 3;
                            out[outIndex++] = charLength2ToByteLength3[tabIndex++];
                            out[outIndex++] = charLength2ToByteLength3[tabIndex++];
                            out[outIndex++] = charLength2ToByteLength3[tabIndex];
                            break;

                        default:
                            if(super.codepageType == 2)
                                out[outIndex++] = 123;
                            else
                                out[outIndex++] = 35;
                            break;
                        }
                        inIndex += 2;
                        continue;
                    }
                } else
                if(in[inIndex] == '\uF8FC')
                {
                    if(inIndex < inEndIndex)
                    {
                        tabIndex = (charLength2ToByteOffset3[charLength2ToByteOffset2[charLength2ToByteOffset1[in[inIndex] >> 8] | in[inIndex] & 0xff] | in[inIndex + 1] >> 8] | in[inIndex + 1] & 0xff) * 3;
                        numBytes = charLength2ToByte[tabIndex];
                        if((outIndex + numBytes) - 1 > outEndIndex)
                            break;
                        switch(numBytes)
                        {
                        case 1: // '\001'
                            if(charLength2ToByte[++tabIndex] != 35)
                            {
                                out[outIndex++] = charLength2ToByte[tabIndex];
                                inIndex += 2;
                                continue;
                            }
                            break;

                        case 2: // '\002'
                            out[outIndex++] = charLength2ToByte[++tabIndex];
                            out[outIndex++] = charLength2ToByte[++tabIndex];
                            inIndex += 2;
                            continue;

                        case 3: // '\003'
                            tabIndex = ((charLength2ToByte[tabIndex + 1] & 0xff) << 8 | charLength2ToByte[tabIndex + 2] & 0xff) * 3;
                            out[outIndex++] = charLength2ToByteLength3[tabIndex++];
                            out[outIndex++] = charLength2ToByteLength3[tabIndex++];
                            out[outIndex++] = charLength2ToByteLength3[tabIndex];
                            inIndex += 2;
                            continue;
                        }
                    }
                } else
                if(in[inIndex] == '\uF8FD' && inIndex + 2 <= inEndIndex)
                {
                    char sapIconChar1 = in[inIndex + 1];
                    char sapIconChar2 = in[inIndex + 2];
                    if((sapIconChar1 >= '0' && sapIconChar1 <= '9' || sapIconChar1 >= 'A' && sapIconChar1 <= 'Z' || sapIconChar1 >= 'a' && sapIconChar1 <= 'z') && (sapIconChar2 >= '0' && sapIconChar2 <= '9' || sapIconChar2 >= 'A' && sapIconChar2 <= 'Z' || sapIconChar2 >= 'a' && sapIconChar2 <= 'z'))
                    {
                        if(outIndex + 3 > outEndIndex)
                            break;
                        if(super.codepageType == 1)
                        {
                            out[outIndex++] = 27;
                            out[outIndex++] = 44;
                            out[outIndex++] = (byte)sapIconChar1;
                            out[outIndex++] = (byte)sapIconChar2;
                            inIndex += 3;
                            continue;
                        }
                        if(super.codepageType == 2)
                        {
                            out[outIndex++] = 27;
                            out[outIndex++] = 107;
                            out[outIndex++] = charLength1ToByte[(charLength1ToByteOffset[0] | sapIconChar1) * 3 + 1];
                            out[outIndex++] = charLength1ToByte[(charLength1ToByteOffset[0] | sapIconChar2) * 3 + 1];
                            inIndex += 3;
                            continue;
                        }
                    }
                }
            tabIndex = (charLength1ToByteOffset[in[inIndex] >> 8] | in[inIndex] & 0xff) * 3;
            numBytes = charLength1ToByte[tabIndex];
            if((outIndex + numBytes) - 1 > outEndIndex)
                break;
            switch(numBytes)
            {
            case 1: // '\001'
                out[outIndex++] = charLength1ToByte[++tabIndex];
                break;

            case 2: // '\002'
                out[outIndex++] = charLength1ToByte[++tabIndex];
                out[outIndex++] = charLength1ToByte[++tabIndex];
                break;

            case 3: // '\003'
                tabIndex = ((charLength1ToByte[tabIndex + 1] & 0xff) << 8 | charLength1ToByte[tabIndex + 2] & 0xff) * 3;
                out[outIndex++] = charLength1ToByteLength3[tabIndex++];
                out[outIndex++] = charLength1ToByteLength3[tabIndex++];
                out[outIndex++] = charLength1ToByteLength3[tabIndex];
                break;

            default:
                if(super.codepageType == 2)
                    out[outIndex++] = 123;
                else
                    out[outIndex++] = 35;
                break;
            }
            inIndex++;
        }
        return outIndex - outBeginIndex;
    }

    public byte[] convert(char in[], int inBeginIndex, int inEndIndex)
    {
        if(in == null)
            return new byte[0];
        if(inBeginIndex < 0)
            return new byte[0];
        if(inBeginIndex >= in.length)
            return new byte[0];
        if(inEndIndex >= in.length)
            inEndIndex = in.length - 1;
        if(inBeginIndex > inEndIndex)
        {
            return new byte[0];
        } else
        {
            int outLength = outLength(in, inBeginIndex, inEndIndex);
            byte out[] = new byte[outLength];
            convert(in, inBeginIndex, inEndIndex, out, 0, outLength - 1);
            return out;
        }
    }

    public byte[] convert(char in[])
    {
        if(in == null)
        {
            return new byte[0];
        } else
        {
            int outLength = outLength(in, 0, in.length - 1);
            byte out[] = new byte[outLength];
            convert(in, 0, in.length - 1, out, 0, outLength - 1);
            return out;
        }
    }

    public int outLength(char in[], int inBeginIndex, int inEndIndex)
    {
        if(in == null)
            return 0;
        if(inBeginIndex < 0)
            return 0;
        if(inBeginIndex >= in.length)
            return 0;
        if(inEndIndex >= in.length)
            inEndIndex = in.length - 1;
        if(inBeginIndex > inEndIndex)
            return 0;
        int outLength = 0;
        int inIndex = inBeginIndex;
        while(inIndex <= inEndIndex) 
        {
            int numBytes;
            if(in[inIndex] >= '\uD800')
                if(in[inIndex] <= '\uDBFF')
                {
                    if(inIndex < inEndIndex && in[inIndex + 1] >= '\uDC00' && in[inIndex + 1] <= '\uDFFF')
                    {
                        numBytes = charLength2ToByte[(charLength2ToByteOffset3[charLength2ToByteOffset2[charLength2ToByteOffset1[in[inIndex] >> 8] | in[inIndex] & 0xff] | in[inIndex + 1] >> 8] | in[inIndex + 1] & 0xff) * 3];
                        if(numBytes > 0 && numBytes < 4)
                            outLength += numBytes;
                        else
                            outLength++;
                        inIndex += 2;
                        continue;
                    }
                } else
                if(in[inIndex] == '\uF8FC')
                {
                    if(inIndex < inEndIndex)
                    {
                        int tabIndex = (charLength2ToByteOffset3[charLength2ToByteOffset2[charLength2ToByteOffset1[in[inIndex] >> 8] | in[inIndex] & 0xff] | in[inIndex + 1] >> 8] | in[inIndex + 1] & 0xff) * 3;
                        numBytes = charLength2ToByte[tabIndex];
                        if(numBytes == 1 && charLength2ToByte[tabIndex + 1] != 35)
                        {
                            outLength++;
                            inIndex += 2;
                            continue;
                        }
                        if(numBytes > 1 && numBytes < 4)
                        {
                            outLength += numBytes;
                            inIndex += 2;
                            continue;
                        }
                    }
                } else
                if(in[inIndex] == '\uF8FD' && inIndex + 2 <= inEndIndex)
                {
                    char sapIconChar1 = in[inIndex + 1];
                    char sapIconChar2 = in[inIndex + 2];
                    if((sapIconChar1 >= '0' && sapIconChar1 <= '9' || sapIconChar1 >= 'A' && sapIconChar1 <= 'Z' || sapIconChar1 >= 'a' && sapIconChar1 <= 'z') && (sapIconChar2 >= '0' && sapIconChar2 <= '9' || sapIconChar2 >= 'A' && sapIconChar2 <= 'Z' || sapIconChar2 >= 'a' && sapIconChar2 <= 'z'))
                    {
                        outLength += 4;
                        inIndex += 3;
                        continue;
                    }
                }
            numBytes = charLength1ToByte[(charLength1ToByteOffset[in[inIndex] >> 8] | in[inIndex] & 0xff) * 3];
            if(numBytes > 0 && numBytes < 4)
                outLength += numBytes;
            else
                outLength++;
            inIndex++;
        }
        return outLength;
    }

    public int outLength(char in[])
    {
        if(in == null)
            return 0;
        else
            return outLength(in, 0, in.length - 1);
    }

    private static final byte TYPE_UNKNOWN = 0;
    private static final byte TYPE_CHARLENGTH1TOBYTEOFFSET_ARRAY = 1;
    private static final byte TYPE_CHARLENGTH1TOBYTE_ARRAY = 2;
    private static final byte TYPE_CHARLENGTH1TOBYTELENGTH3_ARRAY = 3;
    private static final byte TYPE_CHARLENGTH2TOBYTEOFFSET1_ARRAY = 4;
    private static final byte TYPE_CHARLENGTH2TOBYTEOFFSET2_ARRAY = 5;
    private static final byte TYPE_CHARLENGTH2TOBYTEOFFSET3_ARRAY = 6;
    private static final byte TYPE_CHARLENGTH2TOBYTE_ARRAY = 7;
    private static final byte TYPE_CHARLENGTH2TOBYTELENGTH3_ARRAY = 8;
    private char charLength1ToByteOffset[];
    private byte charLength1ToByte[];
    private byte charLength1ToByteLength3[];
    private char charLength2ToByteOffset1[];
    private int charLength2ToByteOffset2[];
    private int charLength2ToByteOffset3[];
    private byte charLength2ToByte[];
    private byte charLength2ToByteLength3[];
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -