C# Class KeePassLib.Utility.StrUtil

A class containing various string helper methods.
Afficher le fichier Open project: cappert/keepass2 Class Usage Examples

Méthodes publiques

Méthode 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

Méthode Description
VersionToString ( ulong uVersion, bool bEnsureAtLeastTwoComp ) : string

Method Details

AddAccelerator() public static méthode

public static AddAccelerator ( string strMenuText, List lAvailKeys ) : string
strMenuText string
lAvailKeys List
Résultat string

AlphaNumericOnly() public static méthode

public static AlphaNumericOnly ( string str ) : string
str string
Résultat string

BoolToString() public static méthode

public static BoolToString ( bool bValue ) : string
bValue bool
Résultat string

BoolToStringEx() public static méthode

public static BoolToStringEx ( bool bValue ) : string
bValue bool
Résultat string

ByteToSafeChar() public static méthode

public static ByteToSafeChar ( byte bt ) : char
bt byte
Résultat char

ColorToUnnamedHtml() public static méthode

/// 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.
Résultat string

CompactString3Dots() public static méthode

public static CompactString3Dots ( string strText, int nMaxChars ) : string
strText string
nMaxChars int
Résultat string

CompareLengthGt() public static méthode

public static CompareLengthGt ( string x, string y ) : int
x string
y string
Résultat int

CompareNaturally() public static méthode

public static CompareNaturally ( string strX, string strY ) : int
strX string
strY string
Résultat int

Count() public static méthode

public static Count ( string str, string strNeedle ) : int
str string
strNeedle string
Résultat int

DataToDataUri() public static méthode

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.
Résultat string

DataUriToData() public static méthode

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

DecryptString() public static méthode

public static DecryptString ( string strCipherText ) : string
strCipherText string
Résultat string

Deobfuscate() public static méthode

public static Deobfuscate ( string strObf ) : string
strObf string
Résultat string

DeserializeIntArray() public static méthode

public static DeserializeIntArray ( string strSerialized ) : int[]
strSerialized string
Résultat int[]

EncodeMenuText() public static méthode

public static EncodeMenuText ( string strText ) : string
strText string
Résultat string

EncodeToolTipText() public static méthode

public static EncodeToolTipText ( string strText ) : string
strText string
Résultat string

EncryptString() public static méthode

public static EncryptString ( string strPlainText ) : string
strPlainText string
Résultat string

FormatDataSize() public static méthode

public static FormatDataSize ( ulong uBytes ) : string
uBytes ulong
Résultat string

FormatDataSizeKB() public static méthode

public static FormatDataSizeKB ( ulong uBytes ) : string
uBytes ulong
Résultat string

FormatException() public static méthode

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

GetEncoding() public static méthode

public static GetEncoding ( StrEncodingType t ) : StrEncodingInfo
t StrEncodingType
Résultat StrEncodingInfo

GetEncoding() public static méthode

public static GetEncoding ( string strName ) : StrEncodingInfo
strName string
Résultat StrEncodingInfo

GetNewLineSeq() public static méthode

public static GetNewLineSeq ( string str ) : string
str string
Résultat string

GetStringBetween() public static méthode

public static GetStringBetween ( string strText, int nStartIndex, string strStart, string strEnd ) : string
strText string
nStartIndex int
strStart string
strEnd string
Résultat string

GetStringBetween() public static méthode

public static GetStringBetween ( string strText, int nStartIndex, string strStart, string strEnd, int &nInnerStartIndex ) : string
strText string
nStartIndex int
strStart string
strEnd string
nInnerStartIndex int
Résultat string

GetUnusedChar() public static méthode

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

IsDataUri() public static méthode

public static IsDataUri ( string strUri ) : bool
strUri string
Résultat bool

IsDataUri() public static méthode

public static IsDataUri ( string strUri, string strReqMimeType ) : bool
strUri string
strReqMimeType string
Résultat bool

IsHexString() public static méthode

public static IsHexString ( string str, bool bStrict ) : bool
str string
bStrict bool
Résultat bool

MultiToSingleLine() public static méthode

public static MultiToSingleLine ( string strMulti ) : string
strMulti string
Résultat string

NormalizeNewLines() public static méthode

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).
Résultat string

NormalizeNewLines() public static méthode

public static NormalizeNewLines ( ProtectedStringDictionary dict, bool bWindows ) : void
dict ProtectedStringDictionary
bWindows bool
Résultat void

Obfuscate() public static méthode

public static Obfuscate ( string strPlain ) : string
strPlain string
Résultat string

ParseVersion() public static méthode

public static ParseVersion ( string strVersion ) : ulong
strVersion string
Résultat ulong

RemoveAccelerator() public static méthode

public static RemoveAccelerator ( string strMenuText ) : string
strMenuText string
Résultat string

RemovePlaceholders() public static méthode

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

ReplaceCaseInsensitive() public static méthode

public static ReplaceCaseInsensitive ( string strString, string strFind, string strNew ) : string
strString string
strFind string
strNew string
Résultat string

RtfEncodeChar() public static méthode

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

SafeXmlString() public static méthode

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.
Résultat string

SerializeIntArray() public static méthode

public static SerializeIntArray ( int vNumbers ) : string
vNumbers int
Résultat string

SimplePatternMatch() public static méthode

public static SimplePatternMatch ( string strPattern, string strText, System.StringComparison sc ) : bool
strPattern string
strText string
sc System.StringComparison
Résultat bool

SplitCommandLine() public static méthode

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.
Résultat void

SplitSearchTerms() public static méthode

public static SplitSearchTerms ( string strSearch ) : List
strSearch string
Résultat List

SplitWithSep() public static méthode

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.
Résultat List

StringToBool() public static méthode

public static StringToBool ( string str ) : bool
str string
Résultat bool

StringToBoolEx() public static méthode

public static StringToBoolEx ( string str ) : bool?
str string
Résultat bool?

StringToHtml() public static méthode

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

StringToTags() public static méthode

public static StringToTags ( string strTags ) : List
strTags string
Résultat List

TagsToString() public static méthode

public static TagsToString ( List vTags, bool bForDisplay ) : string
vTags List
bForDisplay bool
Résultat string

TryParseDateTime() public static méthode

public static TryParseDateTime ( string str, System.DateTime &dt ) : bool
str string
dt System.DateTime
Résultat bool

TryParseInt() public static méthode

public static TryParseInt ( string str, int &n ) : bool
str string
n int
Résultat bool

TryParseIntInvariant() public static méthode

public static TryParseIntInvariant ( string str, int &n ) : bool
str string
n int
Résultat bool

TryParseLong() public static méthode

public static TryParseLong ( string str, long &n ) : bool
str string
n long
Résultat bool

TryParseLongInvariant() public static méthode

public static TryParseLongInvariant ( string str, long &n ) : bool
str string
n long
Résultat bool

TryParseUInt() public static méthode

public static TryParseUInt ( string str, uint &u ) : bool
str string
u uint
Résultat bool

TryParseUIntInvariant() public static méthode

public static TryParseUIntInvariant ( string str, uint &u ) : bool
str string
u uint
Résultat bool

TryParseULong() public static méthode

public static TryParseULong ( string str, ulong &u ) : bool
str string
u ulong
Résultat bool

TryParseULongInvariant() public static méthode

public static TryParseULongInvariant ( string str, ulong &u ) : bool
str string
u ulong
Résultat bool

TryParseUShort() public static méthode

public static TryParseUShort ( string str, ushort &u ) : bool
str string
u ushort
Résultat bool

VersionToString() public static méthode

public static VersionToString ( ulong uVersion ) : string
uVersion ulong
Résultat string

VersionToString() public static méthode

public static VersionToString ( ulong uVersion, uint uMinComp ) : string
uVersion ulong
uMinComp uint
Résultat string

XmlToString() public static méthode

public static XmlToString ( string str ) : string
str string
Résultat string