public unsafe void Add(T slice) { _res.Add((Char16 *)slice.GetUnsafePtr(), slice.Length); }
private static unsafe bool ParseLineImpl(ParseLinesWorker.Info *info, UnsafeRefToNativeHeadRemovableList <Char16> charBuff, UnsafeRefToNativeStringList lines) { // check '\r\n' is overlap between previous buffer and current buffer if (info->check_CR && charBuff.Length > 0) { if (charBuff[0] == UTF16CodeSet.code_LF) { charBuff.RemoveHead(); } } int len_chars = charBuff.Length; Char16 *ptr_chars = (Char16 *)charBuff.GetUnsafePtr(); if (len_chars == 0) { return(false); } for (int i = 0; i < len_chars; i++) { Char16 ch = ptr_chars[i]; // detect ch = '\n' (unix), '\r\n' (DOS), or '\r' (Mac) if (ch == UTF16CodeSet.code_LF || ch == UTF16CodeSet.code_CR) { /* * //Debug.Log(" ** found LF = " + ((int)ch).ToString() + ", i=" + i.ToString() + "/" + charBuff.Length.ToString()); * if (_charBuff[i] == '\n' && i > 0) * { * //Debug.Log(" ** before LF = " + ((int)charBuff[i-1]).ToString()); * } * //*/ lines.Add(ptr_chars, i); if (ch == UTF16CodeSet.code_CR) { if (i + 1 < len_chars) { if (ptr_chars[i + 1] == UTF16CodeSet.code_LF) { i++; //Debug.Log(" ** found CRLF"); } } else { // check '\r\n' or not on the head of next buffer //Debug.LogWarning(" >> checking overlap CRLF"); info->check_CR = true; } } else { info->check_CR = false; } charBuff.RemoveHead(i + 1); return(true); } } return(false); }