svenstaro / rofi-calc

🖩 Do live calculations in rofi!
MIT License
964 stars 31 forks source link

UTF-8 symbols not rendering correctly with -calc-command #108

Closed arades79 closed 11 months ago

arades79 commented 11 months ago

I'm using -calc-command to put the result of the expression into the clipboard (per the example).

When I run a calculation that results in a unicode entity, ex. sin(10 radians) ≈ −0.5440211100, then when I paste I get \342\210\2220.5440211109

I do not run into this issue if I don't use the -calc-command, and instead simply pipe the output to stdout.

This means I could use -terse and simply pipe the output, but I would actually like to see the full expression in history. Regardless, this seems unintended.

~I'm unfamiliar with gio, but I would assume this is related to the gstrescape used in the -calc-command handler. I've run /bin/sh -c 'echo "−0.5440211109" | xclip -sel clip' , and it will correctly place −0.5440211109 into my clipboard, so I don't believe it's a shell or locale configuration issue.~ Actually, I realize that doesn't touch the output value. Instead it must be something in one of the rofi helper functions, could this be an upstream issue?

svenstaro commented 11 months ago

Could be. Gotta be honest, I won't have time to look into this in the near future and I'm also not looking forward to debug C Unicode stuff. Could you look into this?

arades79 commented 11 months ago

Yep! I've been looking to see if I can figure out a simple fix. I just wanted to make sure it wasn't an easy fix for someone super familiar with the codebase before I stuck my hands in too deep.

I'll keep digging and see if I can figure it out, and PR when I do.

arades79 commented 11 months ago

Issue is the g_strescape line, removing it and using the raw string works for what I want, but that probably breaks someone else's use case. g_strescape has a second argument for characters to ignore, and not escape. I'll see if filling that with the symbols qalc uses also fixes it.