/** * String formatting utilities for Internet Object serialization. * Consolidates quoting, escaping, and format detection logic. * Ensures DRY principle and consistent string handling across serialization modules. */ /** * String format types supported by Internet Object */ type StringFormat = 'auto' | 'open' | 'regular' | 'raw' | 'multiline'; /** * Quotes a string value using the appropriate format and encloser. * * @param str The string to quote * @param format The string format to use (default: 'regular') * @param encloser The quote character to use (default: '"') * @returns Properly quoted and escaped string * * @example * ```typescript * quoteString('hello world') * // → "hello world" * * quoteString('it\'s great', 'regular', '"') * // → "it's great" * * quoteString('raw\\ntext', 'raw', "'") * // → 'raw\\ntext' * ``` */ declare function quoteString(str: string, format?: StringFormat, encloser?: string): string; /** * Determines if a string needs quoting to avoid parser ambiguity. * Unquoted strings must not be confused with numbers, booleans, nulls, or dates. * * @param str The string to check * @returns True if the string requires quotes * * @example * ```typescript * needsQuoting('hello') // → false (safe identifier) * needsQuoting('123') // → true (looks like number) * needsQuoting('0001') // → true (looks like number, has leading zeros) * needsQuoting('true') // → true (looks like boolean) * needsQuoting('hello world') // → true (contains space) * needsQuoting('') // → true (empty string) * ``` */ declare function needsQuoting(str: string): boolean; /** * Escapes special characters in a string value. * * @param str String to escape * @param encloser Quote character being used * @returns Escaped string (without quotes) */ declare function escapeString(str: string, encloser?: string): string; /** * Unescapes a quoted string value. * * @param str Escaped string (without quotes) * @returns Unescaped string */ declare function unescapeString(str: string): string; /** * Quotes a string for header definition values. * Always uses regular format with quote encloser for fidelity. * * @param str String to quote for header * @returns Quoted string suitable for header definitions */ declare function quoteHeaderString(str: string): string; /** * Quotes a string for wildcard extra property values. * Uses regular format to avoid parser ambiguity with identifiers. * * @param str String to quote * @returns Quoted string for extra properties */ declare function quoteExtraPropertyString(str: string): string; export { type StringFormat, escapeString, needsQuoting, quoteExtraPropertyString, quoteHeaderString, quoteString, unescapeString };