hoehermann / purple-gowhatsapp

Pidgin/libpurple plugin for WhatsApp Web.
GNU General Public License v3.0
276 stars 34 forks source link

Unicode QR Code garbled #159

Closed heeplr closed 1 year ago

heeplr commented 1 year ago

The unicode/text QR code is a very nice feature, but with spectrum2 + pidgin it doesn't work.

It seems I could get a valid QR-Code if I resize the window to the correct width (didn't try, tho). Could it be that \n are missing?

Unbenannt

hoehermann commented 1 year ago

Thank you for your question.

The textual QR-Code is meant to be used with a monospace font. It is geared towards console applications such as finch. You can try to configure your UI to use a monospace font. Or copy and paste into a code editor that does.

Even though these alternatives exist, I recommend using the QR code in the provided image (I think I can see the link in your screenshot).

heeplr commented 1 year ago

Sure it's a matter of the font? That wouldn't change the amount of lines when resizing the window, would it?

When I resize the window to, let's say ~200 char width, it takes the full width and only uses 6 lines height. When there would be newlines at the end of the line, the amount of lines used wouldn't change, even with larger window widths.

heeplr commented 1 year ago

Wider window example:

Unbenannt

When I copy/paste into a terminal editor, the whole thing uses one line. Not a single \n character.

hoehermann commented 1 year ago

I now understand your problem. For reference: In Pidgin on Ubuntu, it looks like this to me:
shot
(Original as seen in chat window and copied into code editor with monospace font.)

I suspect that either in Spectrum or in Pidgin's XMPP plug-in, the incoming message is expected to be "enhanced" with HTML markup. A newline is discarded since a <br/> is expected.

Based on this example, it looks like qrterminal generates a code of 61x31 characters. To compensate for the stripping, you can save the mangled code to a file and re-insert a newline every 61 glyphs:

grep -Eo '.{61}' qrcode_without_newlines.txt

(Special thanks to https://unix.stackexchange.com/questions/454044/unicode-safe-alternative-for-fold.)

heeplr commented 1 year ago

Ah, I see. I'm not sure where the HTML is stripped but simple newlines aren't stripped. I can

send

messages like this

without problem.

Would it be a dealbreaker for console applications if newline characters would be used instead of <br/>?

The image works without problem so I don't actually need it. I just think it's a lovely feature. But since almost no GUI messenger uses a monospace font, it's no alternative anyway.

Thanks for the explaination and all your work on this.

hoehermann commented 1 year ago

Would it be a dealbreaker for console applications if newline characters would be used instead of <br/>?

I am in fact currently using newlines. I do not know why they are missing in the output you are getting.

The image works without problem so I don't actually need it.

Okay, at least something works. :smiley:

hoehermann commented 1 year ago

I just realized while I can indeed not have <br/> instead of newlines, but I can totally have <br/> and newlines to make everyone happy. I want to add them to the next version.

heeplr commented 1 year ago

Thank you. Works fine now (with monospace font).

Would be awesome if it'd work with all fonts, but that's probably way out of scope.

hoehermann commented 4 months ago

Hi @heeplr. Due to problems with Gajim (see #191) and Pidgin, I changed this again. If you could test and tell me whether https://github.com/hoehermann/purple-gowhatsapp/commit/b30c8b12f7d6782757d6e23b268d86492f587897 is still working for your set-up, that would be great.

Would be awesome if it'd work with all fonts, but that's probably way out of scope.

Yes. Very yes.

heeplr commented 4 months ago

Hi @heeplr. Due to problems with Gajim (see #191) and Pidin, I changed this again. If you could test and tell me whether b30c8b1 is still working for your set-up, that would be great.

I see no problems. Thank you a ton!