-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Description of the issue
Would it be possible to add a predicate CharacterLiteral.getIntValue (or similar) and expand CompileTimeConstantExpr.getIntValue to work for chars as well?
In Java you can perform calculations and comparisons with chars so it would be useful to get its code point value in QL.
Though maybe other programming languages have similar use cases and it would also be useful to add a built-in predicate for the QL string type which allows retrieving the code point value of a string:
- If the string has length 1, then it is the code point value of the contained char
- If the string has length 2, then it tries to get the supplementary code point (only works if the chars form a valid surrogate pair)
- Otherwise no code point exists
Similarly an int::codePointToString() would be useful as well:
- If the value is >=
0x0000and <=0xFFFF, then the result is a string containing a single char with that code point - If the value is >
0xFFFFand <=0x10FFFF, then the result is a string containing two chars which form the respective surrogate pair - Otherwise no result exists
Edit: It looks like conversion from code point int to string will be / has been added as int.toUnicode(), see #6038 (comment).