public static List <string> GetWords(string text) { var words = new List <string>(); var CurrentWord = new StringBuilder(); foreach (char c in text) { if (c == ' ' || c == '\t') { if (CurrentWord.ToString() != "") { words.Add(CurrentWord.ToString()); CurrentWord = new StringBuilder(); } words.Add(c.ToString()); } else { CurrentWord.Append(c.ToString() ); } } if (CurrentWord.ToString() != "") { words.Add(CurrentWord.ToString()); } return(words); }
public static ArrayList GetWords(string text) { ArrayList words = new ArrayList(); StringBuilder CurrentWord = new StringBuilder(); foreach (char c in text.ToCharArray()) { if (c == ' ' || c == '\t') { if (CurrentWord.ToString() != "") { words.Add(CurrentWord.ToString()); CurrentWord = new StringBuilder(); } words.Add(c.ToString (CultureInfo.InvariantCulture)); } else { CurrentWord.Append(c.ToString (CultureInfo.InvariantCulture) ); } } if (CurrentWord.ToString() != "") { words.Add(CurrentWord.ToString()); } return(words); }
public static ArrayList GetWords(string text) { ArrayList words = new ArrayList(); System.Text.StringBuilder CurrentWord = new System.Text.StringBuilder(); for (int i = 0; i < text.Length; i++) { char c = text[i]; if (c == ' ' || c == '\t') { if (CurrentWord.ToString() != "") { words.Add(CurrentWord.ToString()); CurrentWord = new System.Text.StringBuilder(); } words.Add(c.ToString()); } else { CurrentWord.Append(c.ToString()); } } if (CurrentWord.ToString() != "") { words.Add(CurrentWord.ToString()); } return(words); }
public static unsafe void AddString(string Text, Row Row, TextStyle Style, Segment Segment) { if (Text == "") { return; } StringBuilder CurrentWord = new StringBuilder(); char[] Buff = Text.ToCharArray(); fixed(char *c = &Buff[0]) { for (int i = 0; i < Text.Length; i++) { if (c[i] == ' ' || c[i] == '\t') { if (CurrentWord.Length != 0) { Word word = Row.Add(CurrentWord.ToString()); word.Style = Style; word.Segment = Segment; CurrentWord = new StringBuilder(); } Word ws = Row.Add(c[i].ToString (CultureInfo.InvariantCulture)); if (c[i] == ' ') { ws.Type = WordType.xtSpace; } else { ws.Type = WordType.xtTab; } ws.Style = Style; ws.Segment = Segment; } else { CurrentWord.Append(c[i].ToString (CultureInfo.InvariantCulture)); } } if (CurrentWord.Length != 0) { Word word = Row.Add(CurrentWord.ToString()); word.Style = Style; word.Segment = Segment; } } }