Skip to content

Java: Add CharacterLiteral.getIntValue #3635

@Marcono1234

Description

@Marcono1234

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 >= 0x0000 and <= 0xFFFF, then the result is a string containing a single char with that code point
  • If the value is > 0xFFFF and <= 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions