Skip to content

Conversation

lingyv-li
Copy link
Member

@lingyv-li lingyv-li commented Aug 8, 2021

#3140 for Dart target.

Depends on #3119

@lingyv-li lingyv-li changed the title [Dart] Add case changing char stream sample [Dart] Add case changing char stream example Aug 10, 2021
return c;
}
if (upper) {
return String.fromCharCode(c).toUpperCase().codeUnitAt(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use something that doesn't change the length of the output character because it creates problems for mapping to input characters and actually such characters are not used in programming languages.

Your approach change ß to SS (2 chars), I've checked in sandbox:

void main() {
  print("ß".toUpperCase());
}

For instance, you can check the length of the output character, and if it is more than 1 then return the original char. See detail in my comment in a thread about case insensitivity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment, that's a interesting discussion.
In this case it doesn't change the string length because of the .codeUnitAt(0) at the end, but your solution is better. Dart is also a bit special where its behaviour is inconsistent between JS and VM: dart-lang/sdk#6706

@parrt parrt added this to the 4.9.3 milestone Oct 14, 2021
@parrt parrt merged commit fbd2755 into antlr:master Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants