postgres_data_sanitizers.escape =============================== .. py:module:: postgres_data_sanitizers.escape .. autoapi-nested-parse:: Core null character escaping for PostgreSQL compatibility. RULE: Maximum 100 lines per file. Functions --------- .. autoapisummary:: postgres_data_sanitizers.escape.escape_null_chars postgres_data_sanitizers.escape.unescape_null_chars Module Contents --------------- .. py:function:: escape_null_chars(text: str) -> str Escape null characters to Unicode representation for PostgreSQL. **CRITICAL**: PostgreSQL rejects (null character) in TEXT/VARCHAR fields. This was discovered by property-based testing causing: asyncpg.exceptions.UntranslatableCharacterError This function ESCAPES null characters instead of removing them, preserving data integrity. Use unescape_null_chars() to restore. Args: text: Input string that may contain null characters Returns: String with null characters escaped as literal "\u0000" Example: >>> escape_null_chars("helloworld") 'hello\\u0000world' .. py:function:: unescape_null_chars(text: str) -> str Unescape Unicode representation back to null characters. Reverses the escaping done by escape_null_chars(). Args: text: String with escaped null characters Returns: String with literal "\u0000" converted back to Example: >>> unescape_null_chars("hello\\u0000world") 'helloworld'