private string ConvertRune(Rune r) { if (VCF.IsSafeChar(r) || (!r.IsAscii && !UseNonUTF8Escaping)) { return(r.ToString()); } if (r.Value == '\n') { return(UseOldEscaping ? "=\n" : "\n "); } if (UseOldEscaping || !r.IsAscii) { var b = new byte[r.Utf8SequenceLength]; var count = r.EncodeToUtf8(b); return(String.Join(String.Empty, b.Take(count).Select(b => $"={b:X2}"))); } else { return($"\\{r}"); } }
protected Exception UnexpectedEOF(Rune expected, Mark?position = null) { return(new LexerException(position ?? Parser.Position, $"Expected character '{expected.ToString().Replace("'", "\\'")}', got end of file.")); }