stephancasas / alfred-mouseless-messenger

Preview and reply to your messages from within Alfred. Keep your hands on that keyboard!
99 stars 4 forks source link

v2 Non-Ascii Characters in Contact Names Display Incorrectly When Replying #7

Open Stickyhavr opened 1 year ago

Stickyhavr commented 1 year ago

Hello, Just upgraded to v2. Wanted to let you know that any contacts that have accents in their names (José, Lucía, Ordoñez) etc. do display correctly in the list of messages, but do not display correctly on the next screen where you actually type your reply. They all look like this: AÃÉEÄÃez or like AÃÉAÂäa instead of whichever accent it should actually be. Not a deal-breaker at all, but just wanted to make sure you were aware of it. Thanks!

stephancasas commented 1 year ago

Thank you for the heads-up.

I'll encode these before passing them through the data transfer object.

LilDooDoo commented 6 months ago

Hi! I'm also having this issue in May of 2024! Any word on a fix? Thanks!

waynez commented 1 month ago

I came across this issue as well, here is some of my findings about the issue.

The problem is with the character encoding handling, variables are passed between workflows as environment variables, and when it is retrieved using JavaScript, the encoding is already mangled.

const dto = App.systemAttribute('alfred_mm_dto');

This can be proved with below example code

» cat test.js
#!/usr/bin/env osascript -l JavaScript

const App = Application.currentApplication();
App.includeStandardAdditions = true;

const variable = App.systemAttribute('VAR');
console.log(variable);

» VAR='测试' ./test.js
测试

Still trying to figure out a solution, but this is what I got so far.

waynez commented 1 month ago

Thank you for the heads-up.

I'll encode these before passing them through the data transfer object.

The problem is not with the strings in side data transfer object, it is actually with the data transfer object itself.

DTO is a JSON string being passed among different workflows as environment variable, and the passing and processing of a DTO goes through shell & JavaScript engine, which handles character encoding differently. This is how the encoding of the DTO as a whole gets mangled.

A possible solution is to not pass along DTO in plain JSON string, rather to make DTO encoded, for example base64, so it ensures the integrity of the object and its' character encodings.