C# Class KeePassLib.Utility.StrUtil

A class containing various string helper methods.
Mostrar archivo Open project: cappert/keepass2 Class Usage Examples

Public Methods

Method Description
AddAccelerator ( string strMenuText, List lAvailKeys ) : string
AlphaNumericOnly ( string str ) : string
BoolToString ( bool bValue ) : string
BoolToStringEx ( bool bValue ) : string
ByteToSafeChar ( byte bt ) : char
ColorToUnnamedHtml ( Color color, bool bEmptyIfTransparent ) : string

/// Initialize an RTF document based on given font face and size. ///

/// Convert a simple HTML string to an RTF string. ///

Convert a Color to a HTML color identifier string.

CompactString3Dots ( string strText, int nMaxChars ) : string
CompareLengthGt ( string x, string y ) : int
CompareNaturally ( string strX, string strY ) : int
Count ( string str, string strNeedle ) : int
DataToDataUri ( byte pbData, string strMimeType ) : string

Create a data URI (according to RFC 2397).

DataUriToData ( string strDataUri ) : byte[]

Convert a data URI (according to RFC 2397) to binary data.

DecryptString ( string strCipherText ) : string
Deobfuscate ( string strObf ) : string
DeserializeIntArray ( string strSerialized ) : int[]
EncodeMenuText ( string strText ) : string
EncodeToolTipText ( string strText ) : string
EncryptString ( string strPlainText ) : string
FormatDataSize ( ulong uBytes ) : string
FormatDataSizeKB ( ulong uBytes ) : string
FormatException ( Exception excp ) : string

Format an exception and convert it to a string.

GetEncoding ( StrEncodingType t ) : StrEncodingInfo
GetEncoding ( string strName ) : StrEncodingInfo
GetNewLineSeq ( string str ) : string
GetStringBetween ( string strText, int nStartIndex, string strStart, string strEnd ) : string
GetStringBetween ( string strText, int nStartIndex, string strStart, string strEnd, int &nInnerStartIndex ) : string
GetUnusedChar ( string strText ) : char

Find a character that does not occur within a given text.

IsDataUri ( string strUri ) : bool
IsDataUri ( string strUri, string strReqMimeType ) : bool
IsHexString ( string str, bool bStrict ) : bool
MultiToSingleLine ( string strMulti ) : string
NormalizeNewLines ( string str, bool bWindows ) : string

Normalize new line characters in a string. Input strings may contain mixed new line character sequences from all commonly used operating systems (i.e. \r\n from Windows, \n from Unix and \r from Mac OS.

NormalizeNewLines ( ProtectedStringDictionary dict, bool bWindows ) : void
Obfuscate ( string strPlain ) : string
ParseVersion ( string strVersion ) : ulong
RemoveAccelerator ( string strMenuText ) : string
RemovePlaceholders ( string str ) : string

Remove placeholders from a string (wrapped in '{' and '}'). This doesn't remove environment variables (wrapped in '%').

ReplaceCaseInsensitive ( string strString, string strFind, string strNew ) : string
RtfEncodeChar ( char ch ) : string

/// Convert a string into a valid RTF string. ///

SafeXmlString ( string strText ) : string

Removes all characters that are not valid XML characters, according to http://www.w3.org/TR/xml/#charsets .

SerializeIntArray ( int vNumbers ) : string
SimplePatternMatch ( string strPattern, string strText, System.StringComparison sc ) : bool
SplitCommandLine ( string strCmdLine, string &strApp, string &strArgs ) : void

Split up a command line into application and argument.

SplitSearchTerms ( string strSearch ) : List
SplitWithSep ( string str, string vSeps, bool bCaseSensitive ) : List

Split a string and include the separators in the splitted array.

StringToBool ( string str ) : bool
StringToBoolEx ( string str ) : bool?
StringToHtml ( string str ) : string

Convert a string into a valid HTML sequence representing that string.

StringToTags ( string strTags ) : List
TagsToString ( List vTags, bool bForDisplay ) : string
TryParseDateTime ( string str, System.DateTime &dt ) : bool
TryParseInt ( string str, int &n ) : bool
TryParseIntInvariant ( string str, int &n ) : bool
TryParseLong ( string str, long &n ) : bool
TryParseLongInvariant ( string str, long &n ) : bool
TryParseUInt ( string str, uint &u ) : bool
TryParseUIntInvariant ( string str, uint &u ) : bool
TryParseULong ( string str, ulong &u ) : bool
TryParseULongInvariant ( string str, ulong &u ) : bool
TryParseUShort ( string str, ushort &u ) : bool
VersionToString ( ulong uVersion ) : string
VersionToString ( ulong uVersion, uint uMinComp ) : string
XmlToString ( string str ) : string

Private Methods

Method Description
VersionToString ( ulong uVersion, bool bEnsureAtLeastTwoComp ) : string

Method Details

AddAccelerator() public static method

public static AddAccelerator ( string strMenuText, List lAvailKeys ) : string
strMenuText string
lAvailKeys List
return string

AlphaNumericOnly() public static method

public static AlphaNumericOnly ( string str ) : string
str string
return string

BoolToString() public static method

public static BoolToString ( bool bValue ) : string
bValue bool
return string

BoolToStringEx() public static method

public static BoolToStringEx ( bool bValue ) : string
bValue bool
return string

ByteToSafeChar() public static method

public static ByteToSafeChar ( byte bt ) : char
bt byte
return char

ColorToUnnamedHtml() public static method

/// Initialize an RTF document based on given font face and size. /// /// Convert a simple HTML string to an RTF string. /// Convert a Color to a HTML color identifier string.
public static ColorToUnnamedHtml ( Color color, bool bEmptyIfTransparent ) : string
color Color Color to convert.
bEmptyIfTransparent bool If this is true, an empty string /// is returned if the color is transparent.
return string

CompactString3Dots() public static method

public static CompactString3Dots ( string strText, int nMaxChars ) : string
strText string
nMaxChars int
return string

CompareLengthGt() public static method

public static CompareLengthGt ( string x, string y ) : int
x string
y string
return int

CompareNaturally() public static method

public static CompareNaturally ( string strX, string strY ) : int
strX string
strY string
return int

Count() public static method

public static Count ( string str, string strNeedle ) : int
str string
strNeedle string
return int

DataToDataUri() public static method

Create a data URI (according to RFC 2397).
public static DataToDataUri ( byte pbData, string strMimeType ) : string
pbData byte Data to encode.
strMimeType string Optional MIME type. If null, /// an appropriate type is used.
return string

DataUriToData() public static method

Convert a data URI (according to RFC 2397) to binary data.
public static DataUriToData ( string strDataUri ) : byte[]
strDataUri string Data URI to decode.
return byte[]

DecryptString() public static method

public static DecryptString ( string strCipherText ) : string
strCipherText string
return string

Deobfuscate() public static method

public static Deobfuscate ( string strObf ) : string
strObf string
return string

DeserializeIntArray() public static method

public static DeserializeIntArray ( string strSerialized ) : int[]
strSerialized string
return int[]

EncodeMenuText() public static method

public static EncodeMenuText ( string strText ) : string
strText string
return string

EncodeToolTipText() public static method

public static EncodeToolTipText ( string strText ) : string
strText string
return string

EncryptString() public static method

public static EncryptString ( string strPlainText ) : string
strPlainText string
return string

FormatDataSize() public static method

public static FormatDataSize ( ulong uBytes ) : string
uBytes ulong
return string

FormatDataSizeKB() public static method

public static FormatDataSizeKB ( ulong uBytes ) : string
uBytes ulong
return string

FormatException() public static method

Format an exception and convert it to a string.
public static FormatException ( Exception excp ) : string
excp System.Exception Exception to convert/format.
return string

GetEncoding() public static method

public static GetEncoding ( StrEncodingType t ) : StrEncodingInfo
t StrEncodingType
return StrEncodingInfo

GetEncoding() public static method

public static GetEncoding ( string strName ) : StrEncodingInfo
strName string
return StrEncodingInfo

GetNewLineSeq() public static method

public static GetNewLineSeq ( string str ) : string
str string
return string

GetStringBetween() public static method

public static GetStringBetween ( string strText, int nStartIndex, string strStart, string strEnd ) : string
strText string
nStartIndex int
strStart string
strEnd string
return string

GetStringBetween() public static method

public static GetStringBetween ( string strText, int nStartIndex, string strStart, string strEnd, int &nInnerStartIndex ) : string
strText string
nStartIndex int
strStart string
strEnd string
nInnerStartIndex int
return string

GetUnusedChar() public static method

Find a character that does not occur within a given text.
public static GetUnusedChar ( string strText ) : char
strText string
return char

IsDataUri() public static method

public static IsDataUri ( string strUri ) : bool
strUri string
return bool

IsDataUri() public static method

public static IsDataUri ( string strUri, string strReqMimeType ) : bool
strUri string
strReqMimeType string
return bool

IsHexString() public static method

public static IsHexString ( string str, bool bStrict ) : bool
str string
bStrict bool
return bool

MultiToSingleLine() public static method

public static MultiToSingleLine ( string strMulti ) : string
strMulti string
return string

NormalizeNewLines() public static method

Normalize new line characters in a string. Input strings may contain mixed new line character sequences from all commonly used operating systems (i.e. \r\n from Windows, \n from Unix and \r from Mac OS.
public static NormalizeNewLines ( string str, bool bWindows ) : string
str string String with mixed new line characters.
bWindows bool If true, new line characters /// are normalized for Windows (\r\n); if false, new line /// characters are normalized for Unix (\n).
return string

NormalizeNewLines() public static method

public static NormalizeNewLines ( ProtectedStringDictionary dict, bool bWindows ) : void
dict ProtectedStringDictionary
bWindows bool
return void

Obfuscate() public static method

public static Obfuscate ( string strPlain ) : string
strPlain string
return string

ParseVersion() public static method

public static ParseVersion ( string strVersion ) : ulong
strVersion string
return ulong

RemoveAccelerator() public static method

public static RemoveAccelerator ( string strMenuText ) : string
strMenuText string
return string

RemovePlaceholders() public static method

Remove placeholders from a string (wrapped in '{' and '}'). This doesn't remove environment variables (wrapped in '%').
public static RemovePlaceholders ( string str ) : string
str string
return string

ReplaceCaseInsensitive() public static method

public static ReplaceCaseInsensitive ( string strString, string strFind, string strNew ) : string
strString string
strFind string
strNew string
return string

RtfEncodeChar() public static method

/// Convert a string into a valid RTF string. ///
public static RtfEncodeChar ( char ch ) : string
ch char
return string

SafeXmlString() public static method

Removes all characters that are not valid XML characters, according to http://www.w3.org/TR/xml/#charsets .
public static SafeXmlString ( string strText ) : string
strText string Source text.
return string

SerializeIntArray() public static method

public static SerializeIntArray ( int vNumbers ) : string
vNumbers int
return string

SimplePatternMatch() public static method

public static SimplePatternMatch ( string strPattern, string strText, System.StringComparison sc ) : bool
strPattern string
strText string
sc System.StringComparison
return bool

SplitCommandLine() public static method

Split up a command line into application and argument.
public static SplitCommandLine ( string strCmdLine, string &strApp, string &strArgs ) : void
strCmdLine string Command line to split.
strApp string Application path.
strArgs string Arguments.
return void

SplitSearchTerms() public static method

public static SplitSearchTerms ( string strSearch ) : List
strSearch string
return List

SplitWithSep() public static method

Split a string and include the separators in the splitted array.
public static SplitWithSep ( string str, string vSeps, bool bCaseSensitive ) : List
str string String to split.
vSeps string Separators.
bCaseSensitive bool Specifies whether separators are /// matched case-sensitively or not.
return List

StringToBool() public static method

public static StringToBool ( string str ) : bool
str string
return bool

StringToBoolEx() public static method

public static StringToBoolEx ( string str ) : bool?
str string
return bool?

StringToHtml() public static method

Convert a string into a valid HTML sequence representing that string.
public static StringToHtml ( string str ) : string
str string String to convert.
return string

StringToTags() public static method

public static StringToTags ( string strTags ) : List
strTags string
return List

TagsToString() public static method

public static TagsToString ( List vTags, bool bForDisplay ) : string
vTags List
bForDisplay bool
return string

TryParseDateTime() public static method

public static TryParseDateTime ( string str, System.DateTime &dt ) : bool
str string
dt System.DateTime
return bool

TryParseInt() public static method

public static TryParseInt ( string str, int &n ) : bool
str string
n int
return bool

TryParseIntInvariant() public static method

public static TryParseIntInvariant ( string str, int &n ) : bool
str string
n int
return bool

TryParseLong() public static method

public static TryParseLong ( string str, long &n ) : bool
str string
n long
return bool

TryParseLongInvariant() public static method

public static TryParseLongInvariant ( string str, long &n ) : bool
str string
n long
return bool

TryParseUInt() public static method

public static TryParseUInt ( string str, uint &u ) : bool
str string
u uint
return bool

TryParseUIntInvariant() public static method

public static TryParseUIntInvariant ( string str, uint &u ) : bool
str string
u uint
return bool

TryParseULong() public static method

public static TryParseULong ( string str, ulong &u ) : bool
str string
u ulong
return bool

TryParseULongInvariant() public static method

public static TryParseULongInvariant ( string str, ulong &u ) : bool
str string
u ulong
return bool

TryParseUShort() public static method

public static TryParseUShort ( string str, ushort &u ) : bool
str string
u ushort
return bool

VersionToString() public static method

public static VersionToString ( ulong uVersion ) : string
uVersion ulong
return string

VersionToString() public static method

public static VersionToString ( ulong uVersion, uint uMinComp ) : string
uVersion ulong
uMinComp uint
return string

XmlToString() public static method

public static XmlToString ( string str ) : string
str string
return string