System.Xml.XmlComplianceUtil.CDataNormalize C# (CSharp) Méthode

CDataNormalize() public static méthode

public static CDataNormalize ( string value ) : string
value string
Résultat string
        public static string CDataNormalize( string value ) {
            int len = value.Length;

            if ( len <= 0 ) {
               return string.Empty;
            }

            int i = 0;
            int startPos = 0;
            StringBuilder norValue = null;

            while ( i < len ) {
                char ch = value[i];
                if ( ch >= 0x20 || ( ch != 0x9 && ch != 0xA && ch != 0xD ) ) {
                    i++;
                    continue;
                }

                if ( norValue == null ) {
                    norValue = new StringBuilder( len );
                }
                if ( startPos < i ) {
                    norValue.Append( value, startPos, i - startPos );
                }
                norValue.Append( (char)0x20 );

                if ( ch == 0xD && ( i+1 < len && value[i+1] == 0xA ) ) {
                    i += 2;
                }
                else {
                    i++;
                }
                startPos = i;
            }

            if ( norValue == null ) {
                return value;
            }
            else {
               if ( i > startPos ) {
                   norValue.Append(value, startPos, i-startPos);
               }
               return norValue.ToString();
            }
        }