GeometryGym.Ifc.ParserIfc.Decode C# (CSharp) Méthode

Decode() public static méthode

public static Decode ( string str ) : string
str string
Résultat string
        public static string Decode(string str)
        {
            int ilast = str.Length - 4, icounter = 0;
            string result = "";
            while (icounter < ilast)
            {
                char c = str[icounter];
                if(c == '\'')
                {
                    if (icounter + 1 < ilast && str[icounter] == '\'')
                        icounter++;
                }
                if (c == '\\')
                {
                    if (icounter + 3 < ilast && str[icounter + 2] == '\\')
                    {
                        if (str[icounter + 1] == 'S')
                        {
                            char o = str[icounter + 3];
                            result += (char)((int)o + 128);
                            icounter += 3;
                        }
                        else if (str[icounter + 1] == 'X' && str.Length > icounter + 4)
                        {
                            string s = str.Substring(icounter + 3, 2);
                            c = System.Text.Encoding.ASCII.GetChars(BitConverter.GetBytes(Convert.ToInt32(s, 16)))[0];
                            //result += (char)();
                            result += c;
                            icounter += 4;
                        }
                        else
                            result += str[icounter];
                    }
                    else if (str[icounter + 3] == '\\' && str[icounter + 2] == '2' && str[icounter + 1] == 'X')
                    {
                        icounter += 4;
                        while (str[icounter] != '\\')
                        {
                            string s = str.Substring(icounter, 4);
                            c = System.Text.Encoding.Unicode.GetChars(BitConverter.GetBytes(Convert.ToInt32(s, 16)))[0];
                            //result += (char)();
                            result += c;
                            icounter += 4;
                        }
                        icounter += 3;
                    }
                    else
                        result += str[icounter];
                }
                else
                    result += str[icounter];
                icounter++;
            }
            while (icounter < str.Length)
                result += str[icounter++];
            return result;
        }

Usage Example

Exemple #1
0
 internal override void parse(string str, ref int pos, ReleaseVersion release, int len, ConcurrentDictionary <int, BaseClassIfc> dictionary)
 {
     mName        = ParserIfc.Decode(ParserSTEP.StripString(str, ref pos, len));
     mDescription = ParserIfc.Decode(ParserSTEP.StripString(str, ref pos, len));
     mRelatingDraughtingCallout = ParserSTEP.StripLink(str, ref pos, len);
     mRelatedDraughtingCallout  = ParserSTEP.StripLink(str, ref pos, len);
 }
All Usage Examples Of GeometryGym.Ifc.ParserIfc::Decode