Automattic\WooCommerce\EmailEditor\Engine\Renderer

Html2Text::fix_newlinespublic staticWC 1.0

Unify newlines

Converts \r\n to \n, and \r to \n. This means that all newlines (Unix, Windows, Mac) all become \ns.

Method of the class: Html2Text{}

No Hooks.

Returns

String. The fixed text.

Usage

$result = Html2Text::fix_newlines( $text ): string;
$text(string) (required)
Text with any number of \r, \r\n and \n combinations.

Html2Text::fix_newlines() code WC 10.5.0

public static function fix_newlines( string $text ): string {
	// Replace \r\n to \n.
	$text = str_replace( "\r\n", "\n", $text );
	// Remove \rs.
	$text = str_replace( "\r", "\n", $text );

	return $text;
}