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

Encode() public static méthode

public static Encode ( string str ) : string
str string
Résultat string
        public static string Encode(string str)
        {
            string result = "";
            int length = str.Length;
            for (int icounter = 0; icounter < length; icounter++)
            {
                char c = str[icounter];
                if (c == '\r')
                {
                    if(icounter + 1 < length)
                    {
                        if (str[icounter + 1] == '\n' && icounter + 2 == length)
                            return result;
                    }
                    continue;
                }
                if(c == '\n')
                {
                    if (icounter + 1 == length)
                        return result;
                }
                if (c == '\'')
                    result += "\\X\\27"; // Alternative result += "''";
                else
                {
                    int i = (int)c;
                    if (i < 32 || i > 126)
                        result += "\\X2\\" + string.Format("{0:x4}", i).ToUpper() + "\\X0\\";
                    else
                        result += c;
                }
            }
            return result;
        }

Usage Example

 protected override string BuildStringSTEP(ReleaseVersion release)
 {
     return(base.BuildStringSTEP(release) + ",." + mBenchMark.ToString() +
            (string.IsNullOrEmpty(mValueSource) ? ".,$," : ".,'" + ParserIfc.Encode(mValueSource) + "',") +
            (mDataValue == null ? "$" : (mDataValue is BaseClassIfc o ? "#" + o.StepId : mDataValue.ToString())) +
            (mDatabase.Release < ReleaseVersion.IFC4 ? "" : ",#" + mReferencePath.StepId));
 }
All Usage Examples Of GeometryGym.Ifc.ParserIfc::Encode