FormattingUtil
Public / Methods
FormatBytes
Formats the given binary size using up to four decimal digits.
The following units are used:
-
'b': byte -
'kb': kilo-byte (2^10) -
'mb': mega-byte (2^20) -
'gb': giga-byte (2^30) -
'tb': tera-byte (2^40) -
'pb': peta-byte (2^50) -
'eb': exa-byte (2^60)
FormatErrorCode
Formats an error code.
Negative error codes are formatted as decimal numbers (for example: "-123"). Zero is formatted as "0". All other error codes are formatted as hexadecimal numbers with 2, 4 or 8 digits.
FormatMetric
Formats the given metric length in a readable way (e.g. '10.5 cm').
The metric unit is chosen (km, m, cm or mm) so that the resulting string has a minimum number of decimal digits.
FormatReadable
Returns the largest positive nicely readable value that is less than or equal to the given value.
A nicely readable value can be expressed with 10^N*M where N is an integer and M is one of: 1, 2, 5.
For example:
0.1, 0.2, 0.5, 1, 2, 5, 10
GetCharacters
2 overloads
Returns all characters in the given code point range.
Returns all characters that belong to the given categories.
IsSeparatorOrWhitespaceControl
Checks if the given character is a separator or a whitespace control.
This method will return true only in the following cases:
-
IsCategory returns
truefor CharacterCategory.Separator. -
The given character is one of these CharacterCategory.OtherControl characters:
'\u0009','\u000A','\u000B','\u000C','\u000D','\u0085'
The string.Trim method of string trims characters only if IsSeparatorOrWhitespaceControl would return true.
- See also
IsWhitespace
Checks if the given character is a whitespace.
Using this method is equivalent to calling IsCategory with the CharacterCategory.Whitespace flag. However, this method is more efficient.