public IEnumerable <ANSIString> Split(char separator) { int index = 0, newIndex = 0; var sep = new ANSIChar(separator); do { newIndex = _String.IndexOf(sep, index); if (newIndex < 0) { var endstr = new ANSIString(); endstr._String.AddRange(_String.Skip(index)); yield return(endstr); break; } var first = index; index = _String.IndexOf(sep, index); var str = new ANSIString(); str._String.AddRange(_String.Skip(first).Take(index < 0 ? _String.Count - first : index - first)); yield return(str); }while (index >= 0); }
public static ANSIString operator +(string a, ANSIString b) { var ret = new ANSIString(a); ret.Append(b); return(ret); }
public ANSIString Substring(int index, int length = -1) { var ret = new ANSIString(); ret._String.AddRange(_String.Skip(index).Take(length < 0 ? _String.Count - index : length)); return(ret); }
public ANSIString Remove(int index, int length = -1) { var ret = new ANSIString(); ret._String.AddRange(_String.Take(index)); if (length >= 0) { ret._String.AddRange(_String.Skip(index + length)); } return(ret); }
public static ANSIString Join(ANSIString sep, IEnumerable <ANSIString> parts) { ANSIString ret = new ANSIString(); foreach (var part in parts) { ret += part; if (!part.Equals(parts.Last())) { ret += sep; } } return(ret); }
public bool Equals(ANSIString other) { if (Count == other.Count) { for (int i = 0; i < Count; ++i) { if (!this[i].Equals(other[i])) { return(false); } } return(true); } return(false); }
public ANSIString Replace(ANSIString search, ANSIString replace) { int index = 0; ANSIString ret = new ANSIString(this); do { index = PlainString.IndexOf(search.PlainString, index); if (index > 0) { for (int i = 0; i < search.Count; ++i) { ret._String[index + i] = replace[i]; } } }while (index > 0); return(ret); }
public int CompareTo(ANSIString other) { string toCompare = PlainString; return(toCompare.CompareTo(other.PlainString)); }
public void Append(ANSIString other) { _String.AddRange(other._String); }
public ANSIString(ANSIString String) { _String = String._String.Select(c => new ANSIChar(c)).ToList(); }