Uredi

Deli z drugimi prek


String.ReplaceLineEndings Method

Definition

Overloads

ReplaceLineEndings()

Replaces all newline sequences in the current string with NewLine.

ReplaceLineEndings(String)

Replaces all newline sequences in the current string with replacementText.

ReplaceLineEndings()

Source:
String.Manipulation.cs
Source:
String.Manipulation.cs
Source:
String.Manipulation.cs

Replaces all newline sequences in the current string with NewLine.

public:
 System::String ^ ReplaceLineEndings();
public string ReplaceLineEndings ();
member this.ReplaceLineEndings : unit -> string
Public Function ReplaceLineEndings () As String

Returns

A string whose contents match the current string, but with all newline sequences replaced with NewLine.

Remarks

This method searches for all newline sequences within the string and canonicalizes them to match the newline sequence for the current environment. For example, when running on Windows, all occurrences of non-Windows newline sequences will be replaced with the sequence CRLF. When running on Unix, all occurrences of non-Unix newline sequences will be replaced with a single LF character.

It is not recommended that protocol parsers utilize this API. Protocol specifications often mandate specific newline sequences. For example, HTTP/1.1 (RFC 8615) mandates that the request line, status line, and headers lines end with CRLF. Since this API operates over a wide range of newline sequences, a protocol parser utilizing this API could exhibit behaviors unintended by the protocol's authors.

This overload is equivalent to calling ReplaceLineEndings(String), passing NewLine as the replacementText parameter.

This method is guaranteed O(n) complexity, where n is the length of the input string.

Applies to

ReplaceLineEndings(String)

Source:
String.Manipulation.cs
Source:
String.Manipulation.cs
Source:
String.Manipulation.cs

Replaces all newline sequences in the current string with replacementText.

public:
 System::String ^ ReplaceLineEndings(System::String ^ replacementText);
public string ReplaceLineEndings (string replacementText);
member this.ReplaceLineEndings : string -> string
Public Function ReplaceLineEndings (replacementText As String) As String

Parameters

replacementText
String

The text to use as replacement.

Returns

A string whose contents match the current string, but with all newline sequences replaced with replacementText.

Remarks

This method searches for all newline sequences within the string and canonicalizes them to the newline sequence provided by replacementText. If replacementText is Empty, all newline sequences within the string will be removed.

It is not recommended that protocol parsers utilize this API. Protocol specifications often mandate specific newline sequences. For example, HTTP/1.1 (RFC 8615) mandates that the request line, status line, and headers lines end with CRLF. Since this API operates over a wide range of newline sequences, a protocol parser utilizing this API could exhibit behaviors unintended by the protocol's authors.

The list of recognized newline sequences is CR (U+000D), LF (U+000A), CRLF (U+000D U+000A), NEL (U+0085), LS (U+2028), FF (U+000C), and PS (U+2029). This list is given by the Unicode Standard, Sec. 5.8, Recommendation R4 and Table 5-2.

This method is guaranteed O(n * r) complexity, where n is the length of the input string, and where r is the length of replacementText.

Applies to