Aurora.ScriptEngine.AuroraDotNetEngine.APIs.LSL_Api.llBase64ToInteger C# (CSharp) Метод

llBase64ToInteger() публичный Метод

Converts an eight character base-64 string into a 32-bit integer.
This is coded to behave like LSL's implementation (I think), based upon the information available at the Wiki. If more than 8 characters are supplied, zero is returned. If a NULL string is supplied, zero will be returned. If fewer than 6 characters are supplied, then the answer will reflect a partial accumulation.

The 6-bit segments are extracted left-to-right in big-endian mode, which means that segment 6 only contains the two low-order bits of the 32 bit integer as its high order 2 bits. A short string therefore means loss of low-order information. E.g. |<---------------------- 32-bit integer ----------------------->|<-Pad->| |<--Byte 0----->|<--Byte 1----->|<--Byte 2----->|<--Byte 3----->|<-Pad->| |3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1| | | | | | | | | | |P|P|P|P| |1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|P|P|P|P| | str[0] | str[1] | str[2] | str[3] | str[4] | str[6] |

public llBase64ToInteger ( string str ) : Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLInteger
str string // 8 characters string to be converted. Other // length strings return zero. //
Результат Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLInteger
        public LSL_Integer llBase64ToInteger(string str)
        {
            int number = 0;
            int digit;

            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return 0;


            //    Require a well-fromed base64 string

            if (str.Length > 8)
                return 0;

            //    The loop is unrolled in the interests
            //    of performance and simple necessity.
            //
            //    MUST find 6 digits to be well formed
            //      -1 == invalid
            //       0 == padding

            if ((digit = c2itable[str[0]]) <= 0)
            {
                return digit < 0 ? 0 : number;
            }
            number += --digit << 26;

            if ((digit = c2itable[str[1]]) <= 0)
            {
                return digit < 0 ? 0 : number;
            }
            number += --digit << 20;

            if ((digit = c2itable[str[2]]) <= 0)
            {
                return digit < 0 ? 0 : number;
            }
            number += --digit << 14;

            if ((digit = c2itable[str[3]]) <= 0)
            {
                return digit < 0 ? 0 : number;
            }
            number += --digit << 8;

            if ((digit = c2itable[str[4]]) <= 0)
            {
                return digit < 0 ? 0 : number;
            }
            number += --digit << 2;

            if ((digit = c2itable[str[5]]) <= 0)
            {
                return digit < 0 ? 0 : number;
            }
            number += --digit >> 4;

            // ignore trailing padding

            return number;
        }
LSL_Api