public unsafe Range Find(int startPos, int endPos, string searchString, SearchFlags flags) { TextToFind ttf = new TextToFind(); ttf.chrg.cpMin = startPos; ttf.chrg.cpMax = endPos; fixed(byte *pb = Scintilla.Encoding.GetBytes(searchString)) { ttf.lpstrText = (IntPtr)pb; int pos = NativeScintilla.FindText((int)flags, ref ttf); if (pos >= 0) { return(new Range(pos, pos + searchString.Length, Scintilla)); } else { return(null); } } }