Bug with $KMVAR for special chars?

I have a macro to download a file that has ñ on the name. The file name is being passed to the Execute Shell Script macro as KMVAR_variable, but KMVAR_variable contains %CC% instead of ñ.

How can I preserve the special characters inside KMVAR_variable so it downloads the proper file?

Creating an env. variable ENV_LC_ALL to “en_US.UTF-8” didn't make a difference. :frowning:

It worked fine in my quick test. I created a file called “ñ” in my home directory and ran this macro and it worked fine for me. So perhaps something else is going on.

I tried your code and it works fine. The problem seems to happen when passing a KMVAR to wget.

When I put the URL in a KMVAR, I get an error.

error

But when I type the variable directly I don't.

Please upload your macro so we can test.
See How to post/upload your script/macro.

Execute a Shell Script.kmactions (803 B)

A glitch in wget rather than KM, perhaps ?

Please do not upload your macro to a new topic.
Just append it to the topic where the request was made.
Please see the instructions in:

Also, the entity you uploaded was only one Action. Please upload the entire macro. Upload it here.

@JMichaelTX the entire macro can be seen in the picture above.

@ComplexPoint not a glitch from wget because the command works fine when I type it outside of keyboard maestro.

On terminal:
wget http://testsite.kinsta.cloud/wp-content/uploads/2019/04/ña.png
(works fine)

But this throws an error:

There are two ways of representing ñ.

It can be represented as a precomposed or decomposed format. They have the UTF sequences of either:

  • 6E n
  • CC .
  • 83 .

The other is:

  • C3 .
  • B1 .

The characters are conically equivalent, but have different unicode encodings.

The server is expecting one and not the other, and depending on how the text is transferred to the environment you get one or the other.

So you need to figure out a way to convert the text to precomposed or decomposed format in order to make the URL work. Maybe you could use the uconv shell tool. Alternatively, you can properly format the URL by pre-encoding the UTF8 characters, for example:

NOTE: The Set Variable to Text action has turned off text token processing so as not to muck around with the % characters!

1 Like

I tried to create a macro to encode the url but realized how KM is so versatile. I just had it type the command in the terminal multiple times instead of running it from Execute Shell Script macro and all problems solved.

@JMichaelTX @ComplexPoint, @peternlewis I learned a lot from your replies to this topic, thank you so much for your time.