ant-design-blazor/site/AntDesign.Docs/Utils/StringExtensions.cs
2021-02-06 20:15:46 +08:00

32 lines
810 B
C#

using System;
namespace AntDesign.Docs.Utils
{
public static class StringExtensions
{
public static string TrimWhiteSpace(this string str)
{
if (str == null)
{
return null;
}
char[] whiteSpace = { '\r', '\n', '\f', '\t', '\v' };
return str.Trim(whiteSpace).Trim();
}
public static string FixLineBreakForWeb(this string str)
{
return str.Replace(Environment.NewLine, "<br/>");
}
public static string FixTabsForWeb(this string str)
{
return str.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
}
public static string FixSpaceForWeb(this string str)
{
return str.Replace(" ", "&nbsp;");
}
}
}