pythongolfer icon indicating copy to clipboard operation
pythongolfer copied to clipboard

Reversed coated string in result code

Open clemg opened this issue 4 years ago • 6 comments

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 avatar Jan 17 '21 11:01 clemg

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).

matytyma avatar Apr 11 '23 14:04 matytyma

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

clemg avatar Apr 12 '23 09:04 clemg

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 avatar Apr 12 '23 12:04 matytyma

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

matytyma avatar Apr 12 '23 12:04 matytyma

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 😄

clemg avatar Apr 13 '23 12:04 clemg

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 :sweat_smile:)

matytyma avatar Apr 13 '23 12:04 matytyma