Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reversed coated string in result code #2

Open
clemg opened this issue Jan 17, 2021 · 7 comments
Open

Reversed coated string in result code #2

clemg opened this issue Jan 17, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@clemg
Copy link
Owner

clemg commented Jan 17, 2021

Describe the bug
When the input code contains ". ", the coating code is reversed and sometimes appears in the middle.
For some reasons, it does not happen every time, it depends on the position of the ". " string.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://clemg.github.io/pythongolfer/
  2. Enter a code with ". " in it
  3. Click the "Golf it!" button
  4. See error

Expected behavior
The result code should appear coated with the decoding python code, but instead we get a reversed string in the middle.

Screenshots

Desktop or Smartphone (please complete the following information):

  • OS: Windows 10
  • Browser Firefox
  • Version 84.0.2 (64 bits)

Edit: also works with "+ " in it.
Theory: Maybe when the "+" or the "." is in an even indice position in the string, the converted char in UTF-16 is a reversing one, it would explain what this happens only in this precise case.

@clemg clemg added the bug Something isn't working label Jan 17, 2021
@clemg clemg self-assigned this Jan 17, 2021
@matytyma
Copy link

In my opinion, the reason is, that it maps to a character that changes the direction of text, so it should work until pasted to some editor, that will remove such characters.

Could you try to copy the bugged result and post it somewhere on Discord? The reason why I'm suggesting it is that Discord removes text direction-changing characters).

@clemg
Copy link
Owner Author

clemg commented Apr 12, 2023

But if the character is removed (through discord for instance) the decoded golfed code won't be the expected one, it will cause a 2 characters loss

@matytyma
Copy link

matytyma commented Apr 12, 2023

Yeah, the code won't work as expected after the removal, but it'll confirm what I said and show that the code is valid. It only renders from the right side, but it's not actually reversed. Haven't yet found any IDE, that would remove the character.

@matytyma
Copy link

But this is an actual issue:
Code (Replaced the actual character U+202E (RLO) with the text '-RLO-'

print("-RLO-Lol, this is a funny test")

image

@clemg
Copy link
Owner Author

clemg commented Apr 13, 2023

I see what you did
My take on this is to leave it as is, or maybe add a bigger disclaimer when this is encountered

Removing/changing the code isn't a solution in my opinion
If you have another idea, feel free to submit it 😄

@matytyma
Copy link

I'm too lazy to code in JavaScript, so here you're somewhat you could do:

When the code contains any of the characters specified in the link I posted above and warn the user then
If the original code contains the character, warn that it might produce different strings
If the golfed code contains it, warn that it only does not render well, but the code will work as expected (not in Linux terminal 😅)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@clemg @matytyma and others