classUnicodeEscapes
final class UnicodeEscapes
Replaces the Unicode escapes of U&'...' strings and U&"..." identifiers.
Rule: PG-LEX-UNICODE-001. An escape is the escape character followed by four hexadecimal digits, or by + and six; the escape character written twice stands for itself. A surrogate pair written as two escapes is one character. The result is UTF-8, the server encoding the profile fixes. The server rejects a malformed escape, a lone surrogate and code point zero while scanning, so they are SQL outside the grammar. Source: https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-UESCAPE. Status: Implemented.
Methods§
public function decode(string $text, string $escape): stringDecodes text whose quotes are already undoubled.
Parameters
$text | string | The text between the quotes |
$escape | string | The escape character |
Returns
stringTest cases 4
Called from 2
Calls 7
- function-call
strlenline 35 - method-call UnicodeEscapes::reject() line 38
- function-call
strcspnline 39 - function-call
substrline 40 - function-call
preg_matchline 50 - function-call
hexdecline 52 - method-call UnicodeEscapes::encode() line 55
public function encode(int $point): stringEncodes one code point as UTF-8, rejecting the values the server rejects.
Parameters
$point | int |
Returns
stringTest cases 2
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::escape() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:168
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::escape() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:171
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::decode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:55
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::decode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:60
Calls 2
- method-call UnicodeEscapes::reject() line 73
- function-call
chrline 75
public function reject(bool $condition, string $message): voidReports text the server rejects while scanning (str_udeescape of parser.c, called for each UIDENT and USCONST token).
Parameters
$condition | bool | |
$message | string |
Throws
AnalysisException When the condition holdsTest cases 1
Called from 6
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::decode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:38
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::decode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:45
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::decode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:50
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::decode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:54
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::decode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:63
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\UnicodeEscapes::encode() packages/sql-semantics-postgres/src/Rules/Lexical/UnicodeEscapes.php:73
Calls 1
Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
UnicodeEscapesTest::testDecodeJoinsASurrogatePaircallsUnicodeEscapesTest::testDecodeRejectsALoneSurrogatecallsUnicodeEscapesTest::testDecodeRejectsAMalformedEscapecallsUnicodeEscapesTest::testDecodeReplacesFourAndSixDigitEscapescallsUnicodeEscapesTest::testEncodeRejectsCodePointZerocallsUnicodeEscapesTest::testEncodeWritesUtf8callsUnicodeEscapesTest::testRejectThrowsOnlyWhenTheConditionHoldscalls
Relations§
Instantiated in 4
- new SqlSemantics\Platform\PostgreSql\Rules\Identifiers::decode() packages/sql-semantics-postgres/src/Rules/Identifiers.php:45
- new SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::decode() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:51
- new SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::escape() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:168
- new SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::escape() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:171
Method calls 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Identifiers::decode() packages/sql-semantics-postgres/src/Rules/Identifiers.php:45
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::decode() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:51
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::escape() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:168
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Strings::escape() packages/sql-semantics-postgres/src/Rules/Lexical/Strings.php:171