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

📄 sapchartoutf8byteconverter.java

📁 SAP这个系统的一个转换器
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SAPCharToUTF8ByteConverter.java

package com.sap.mw.jco.util;


// Referenced classes of package com.sap.mw.jco.util:
//            BasicSAPConverter, SAPCharToByteConverter

public class SAPCharToUTF8ByteConverter extends BasicSAPConverter
    implements SAPCharToByteConverter
{

    protected SAPCharToUTF8ByteConverter(String charEncoding)
    {
        super(charEncoding);
        super.codepageType = 1;
    }

    public int convert(char in[], int inBeginIndex, int inEndIndex, byte out[], int outBeginIndex, int outEndIndex)
    {
        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;
        if(out == null)
            return 0;
        if(outBeginIndex < 0)
            return 0;
        if(outBeginIndex >= out.length)
            return 0;
        if(outEndIndex >= out.length)
            outEndIndex = out.length - 1;
        if(outBeginIndex > outEndIndex)
            return 0;
        int inIndex = inBeginIndex;
        int outIndex = outBeginIndex;
        while(inIndex <= inEndIndex && outIndex <= outEndIndex) 
        {
            if(in[inIndex] < '\200')
            {
                out[outIndex++] = (byte)in[inIndex++];
                continue;
            }
            if(in[inIndex] < '\u0800')
            {
                if(outIndex == outEndIndex)
                    break;
                out[outIndex++] = (byte)(in[inIndex] >> 6 | 0xc0);
                out[outIndex++] = (byte)(in[inIndex++] & 0x3f | 0x80);
                continue;
            }
            if(in[inIndex] < '\uD800' || in[inIndex] > '\uDFFF')
            {
                if(outIndex + 2 > outEndIndex)
                    break;
                out[outIndex++] = (byte)(in[inIndex] >> 12 | 0xe0);
                out[outIndex++] = (byte)(in[inIndex] >> 6 & 0x3f | 0x80);
                out[outIndex++] = (byte)(in[inIndex++] & 0x3f | 0x80);
                continue;
            }
            if(in[inIndex] > '\uDBFF')
            {
                out[outIndex++] = 35;
                inIndex++;
                continue;
            }
            if(inIndex == inEndIndex)
            {
                out[outIndex++] = 35;
                break;
            }
            if(in[inIndex + 1] < '\uDC00' || in[inIndex + 1] > '\uDFFF')
            {
                out[outIndex++] = 35;
                inIndex++;
            } else
            {
                int charid = ((in[inIndex] & 0x3ff) << 10 | in[inIndex + 1] & 0x3ff) + 0x10000;
                out[outIndex++] = (byte)(charid >> 18 | 0xf0);
                out[outIndex++] = (byte)(charid >> 12 & 0x3f | 0x80);
                out[outIndex++] = (byte)(charid >> 6 & 0x3f | 0x80);
                out[outIndex++] = (byte)(charid & 0x3f | 0x80);
                inIndex += 2;
            }
        }
        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) 
        {
            if(in[inIndex] < '\200')
            {
                outLength++;
                inIndex++;
                continue;
            }
            if(in[inIndex] < '\u0800')
            {
                outLength += 2;
                inIndex++;
                continue;
            }
            if(in[inIndex] < '\uD800' || in[inIndex] > '\uDFFF')
            {
                outLength += 3;
                inIndex++;
                continue;
            }
            if(in[inIndex] > '\uDBFF')
            {
                outLength++;
                inIndex++;
                continue;
            }
            if(inIndex == inEndIndex)
            {
                outLength++;
                break;
            }
            if(in[inIndex + 1] < '\uDC00' || in[inIndex + 1] > '\uDFFF')
            {
                outLength++;
                inIndex++;
            } else
            {
                outLength += 4;
                inIndex += 2;
            }
        }
        return outLength;
    }

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

⌨️ 快捷键说明

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