如何在 C# 中读取 SQLite 数据库中的换行符?
How to read in C# the Newline character in a SQLite database?
我目前正在开发的应用程序需要检索存储在 SQLite
数据库中的 TEXT
字段中的 Newline (\n)
字符。 SQLite中\n
对应的字符是什么?
因为
string[] words = str.Split(new string[] { @"\r\n" }, StringSplitOptions.None);
好像不行。
string[] words = str.Split(new string[] { "\r\n" }, StringSplitOptions.None);
在""
之前没有@
,否则就是\
和r
和\
和n
...或者试试
string[] words = str.Split(new string[] { "\n" }, StringSplitOptions.None);
取决于程序在数据库中保存的内容。
现在,如果你真的想抓到任何东西,你可以...
string[] words = str.Split(new[] { "\r\n", "\r", "\n", StringSplitOptions.None);
A verbatim string literal consists of an @ character followed by a
double-quote character, zero or more characters, and a closing
double-quote character. A simple example is @"hello". In a verbatim
string literal, the characters between the delimiters are interpreted
verbatim, the only exception being a quote-escape-sequence. In
particular, simple escape sequences and hexadecimal and Unicode
escape sequences are not processed in verbatim string literals. A
verbatim string literal may span multiple lines.
您可以随时使用 Environment.NewLine。
// Summary:
// Gets the newline string defined for this environment.
//
// Returns:
// A string containing "\r\n" for non-Unix platforms, or a string containing
// "\n" for Unix platforms.
public static string NewLine { get; }
string[] words = str.Split(new[] { Environment.NewLine} , StringSplitOptions.None);
我目前正在开发的应用程序需要检索存储在 SQLite
数据库中的 TEXT
字段中的 Newline (\n)
字符。 SQLite中\n
对应的字符是什么?
因为
string[] words = str.Split(new string[] { @"\r\n" }, StringSplitOptions.None);
好像不行。
string[] words = str.Split(new string[] { "\r\n" }, StringSplitOptions.None);
在""
之前没有@
,否则就是\
和r
和\
和n
...或者试试
string[] words = str.Split(new string[] { "\n" }, StringSplitOptions.None);
取决于程序在数据库中保存的内容。
现在,如果你真的想抓到任何东西,你可以...
string[] words = str.Split(new[] { "\r\n", "\r", "\n", StringSplitOptions.None);
A verbatim string literal consists of an @ character followed by a double-quote character, zero or more characters, and a closing double-quote character. A simple example is @"hello". In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence. In particular, simple escape sequences and hexadecimal and Unicode escape sequences are not processed in verbatim string literals. A verbatim string literal may span multiple lines.
您可以随时使用 Environment.NewLine。
// Summary:
// Gets the newline string defined for this environment.
//
// Returns:
// A string containing "\r\n" for non-Unix platforms, or a string containing
// "\n" for Unix platforms.
public static string NewLine { get; }
string[] words = str.Split(new[] { Environment.NewLine} , StringSplitOptions.None);