Table of Contents

TTMSFNCUtils Class

Collection of framework-neutral utility class methods covering string manipulation, file I/O, encoding, JSON, date/time, DPI scaling, bitmap conversion, and miscellaneous helpers used across all TMS FNC components.

API unit family: TMSFNCUtils

Syntax

TTMSFNCUtils = class

Methods

Name Description
AddBackslash Returns AValue with a trailing backslash appended if not already present.
AddCharSet Combines two character sets.
AddForwardslash Returns AValue with a trailing forward slash appended if not already present.
AlphaCharSet Returns a character set containing ASCII letters.
CharInSet Returns whether a character belongs to a character set.
CharInStr Returns the character at the 1-based position Index within s.
CheckVCLStylesEnabled Returns whether VCL styles are active for the current context.
Clone Creates and returns a deep clone of AComponent by streaming its published properties.
ClosingParenthesis Finds the closing parenthesis for an expression segment.
ConvertBitmapToJPEGStream Converts a bitmap to a JPEG stream using the common graphics color type.
CreateBitmapFromBase64 Creates a bitmap from a Base64-encoded image stream.
CreateBitmapFromHexStr Creates a bitmap from a hexadecimal-encoded image stream.
CreateCharSet Creates a character set from a string.
DateTimeToISO Formats a date/time value as an ISO-like string.
DateTimeToMilliSeconds Converts a date/time value to Unix milliseconds.
DateTimeToUTC Formats a date/time value as a UTC date/time string.
DateToISO Formats a date value as an ISO-like string.
Decode64 Decodes a Base64 string.
Decode64ToBytes Decodes a Base64 string to bytes.
DownloadImage Downloads image data from a URL into a memory stream.
EnDeCrypt Applies a symmetric encryption/decryption transformation to AValue; calling it twice returns the original string.
Encode64 Encodes a string as Base64.
EpochToDateTime Converts a Unix epoch value to a Delphi date/time value.
EscapeString Escapes a string for safe use in JSON-style text.
FileToBase64 Reads a file and returns its content as Base64.
FindGraphicClass Finds the registered graphic class that can load the specified image buffer.
FindJSONValue Finds a JSON value by path.
FirstChar Finds the first character from a character set in a string.
FixMarkup Encodes characters as HTML markup entities.
FloatToStrDot Converts a floating-point value to a string with a dot decimal separator.
FormatBytesAsString Formats a byte count using an appropriate size suffix.
GetAppPath Returns the directory from which the current executable was launched.
GetBestDelimiter Chooses the most likely delimiter for delimited text.
GetDPIScale Returns the DPI scale factor for the screen or form that owns AOwner.
GetDocumentsPath Returns the platform-specific path to the user's documents folder.
GetFileExtension Returns the registered file extension for a MIME type.
GetFonts Populates FontList with the names of all fonts available on the current system.
GetHInstance Returns the application module instance handle.
GetImageType Detects the image file extension represented by stream header bytes.
GetJSONArrayItem Returns an item from a JSON array.
GetJSONArraySize Returns the number of items in a JSON array.
GetJSONDoubleValue Returns a JSON object property as a floating-point value.
GetJSONIntegerValue Returns a JSON object property as an integer value.
GetJSONObjectItem Returns a JSON object value by index.
GetJSONObjectName Returns a JSON object property name by index.
GetJSONObjectSize Returns the number of name/value pairs in a JSON object.
GetJSONProp Returns the string value of a JSON object property.
GetJSONValue Returns a direct property value from a JSON object.
GetJSONValueAsBoolean Converts a JSON value to a Boolean.
GetJSONValueAsDouble Converts a JSON value to a floating-point value.
GetJSONValueAsInteger Converts a JSON value to an integer value.
GetJSONValueAsString Converts a JSON value to its compact string representation.
GetMarkupIndex Returns the index of an HTML entity name in the internal markup table.
GetMimeType Returns the MIME type associated with a file name or extension.
GetMousePos Returns the current mouse cursor position in screen coordinates.
GetOwnerForm Returns the form that owns or contains a component.
GetParentForm Returns the parent form for an FMX object.
GetResourceStream Returns a stream for the embedded resource named AResourceName from the application module.
GetSpecialChar Returns the Unicode character for an internal special-character index.
GetStrIdx Returns the index of a matching value in an array.
GetTempPath Returns the platform-specific temporary files directory.
HTMLStrip Returns a plain-text copy of AHTML with all HTML tags removed.
HexStrToBytes Converts a hexadecimal string to a byte array.
IPos Finds a substring using a case-insensitive comparison.
ISOToDate Parses an ISO-like date string.
ISOToDateTime Parses an ISO-like date/time string.
IndexOfTextInArray Finds text in an array using case-insensitive comparison.
IsDate Attempts to parse a date or date/time string using current format settings.
IsHTML Returns True if AValue contains HTML markup.
IsHTMLUnicode Returns True if AValue contains HTML markup in Unicode form.
IsHighDPIScale Returns True if the application is running at a DPI scale greater than 100%.
IsJSON Returns whether a string can be parsed as JSON.
IsJSONFalse Returns whether a JSON value is the literal false.
IsJSONTrue Returns whether a JSON value is the literal true.
IsLetterOrDigit Returns whether a character is a letter or digit.
LoadBitmapFromBase64 Loads a bitmap from Base64-encoded image data.
LoadBitmapFromHexStr Loads a bitmap from a hexadecimal-encoded image stream.
LoadBitmapFromImageList Loads a bitmap from an image list item.
LoadFile Loads file data and invokes a completion callback.
LoadStreamFromBase64 Decodes Base64 data into a stream.
LoadStreamFromHexStr Decodes hexadecimal data into a stream.
Log Writes a message to the platform debug log.
MatchStr Compares a value with a wildcard pattern.
MatchStrEx Compares a value with an expression or wildcard pattern.
Matches Compares a null-terminated string with a wildcard pattern.
MulDivInt Multiplies an integer by a numerator and divides by a denominator with rounding.
MulDivSingle Multiplies a floating-point value by a numerator and divides by a denominator.
NSStrEx Converts a Delphi string to an Objective-C NSString.
NumericCharSet Returns a character set containing digits.
OpenFile Opens the specified file using the default system application associated with its file type.
OpenURL Opens the specified URL in the default system browser or handler.
ParseJSON Parses a JSON string.
PlayAudio Plays audio data encoded as Base64.
SaveBitmapToBase64 Encodes the current bitmap content as a Base64 string.
SaveBitmapToHexStr Encodes the current bitmap content as a hexadecimal string.
SaveFile Shows a save-file dialog or platform file picker.
SaveStreamToBase64 Encodes all bytes of AStream to a Base64 string.
SaveStreamToHexStr Serializes all bytes of AStream to a lowercase hexadecimal string.
ScaleForCurrentDPI Scales all controls on AForm to match the current system DPI.
ScaleForDPI Scales AControl and its children to match the specified DPI.
SelectFile Shows an open-file dialog or platform file picker.
SetFontSize Sets the font size in points, adjusting for an optional DPI scale factor.
Split Splits a string into a destination string list using a single-character delimiter.
SplitURL Splits a URL into host, path, query, and port parts.
StrToFloatDot Converts a string with a dot decimal separator to a floating-point value.
StripLogicSpaces Removes spaces that surround logical expression operators.
StripThousandSep Removes thousands separators and normalizes the decimal separator to a dot.
SubCharSet Removes one character set from another.
TagReplaceString Replaces all occurrences of a tag or entity string inside a destination string.
TryStrToFloatDot Attempts to convert a string with a dot decimal separator to a floating-point value.
URLDecode Decodes a percent-encoded URL string back to a plain string.
URLEncode Encodes a plain string into a percent-encoded URL-safe string.
UnFixMarkup Decodes HTML markup entities to characters.
UnescapeString Unescapes a string containing JSON-style escape sequences.
VarPos Finds the first occurrence of ASubValue in AValue and stores the 1-based position in AResult.
VarPosNoCase Case-insensitive variant of VarPos: finds the first occurrence of ASubValue in AValue and stores the result.

Used by