Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Use Special character in Formula tool

Hakimipous
10 - Fireball

Hello,

 

I have been using cpdf to generate Password protected PDF via a macro.

 

It works great, except for for files containing special characters. Those can't seems to work with the Alteryx Command tool, but have to be handled manually via the Windows Command Tool.

 

for example : in Alteryx I use the following command : 

 

' "Z:\XXX\cpdf.exe" ' + ' -encrypt AES " "  "test" -i '+ ' " Z\XXX\Calmîc forecast.pdf " ' + ' -o ' + ' " Z:\XXX\Calmîc forecast.pdf " '   

 

and when it opens the opens the Command tool, Calmîc becomes Calm-c, or something like that.

 

I guess It has to do with Alteryx having issues with that kind of special characters, because when I do it manually directly into the Windows Command Tool it works.

 

Any idea if I can make Alteryx read those kind of characters with the Command Tool?

 

Thanks !

6 REPLIES 6
KevinP
Alteryx Alumni (Retired)

@Hakimipous I did some testing around this, and had no issues with your command calling it directly in the Run Command tool, or running it via a PowerShell script. However, if I tried to use the command in a batch script the Windows cmd prompt wouldn't recognize the unicode character. In testing the unicode character was dropped which causes the command to fail. This occurred even though the bat file was created with the correct characters in the command, and when the bat file was called directly from the cmd prompt as well as via the Run Command tool. As such it  appears this issue is due to a limitation of batch scripts rather than an issue with the Run Command tool.

 

2018-01-25_15-05-47.png

 

As you can see in the bat file the ' î ' is clearly present in the command, but when the bat file is run from the command line this unicode character is left out. I have attached my testing samples for this along with working samples using PowerShell script and the Run Command tool directly. Please note these samples assume both cpdf.exe and your PDF file are in C:\temp\cpdfTest\ please update the paths as appropriate for your testing.

Hakimipous
10 - Fireball

Thanks @KevinP ! 

 

I have to admit that's an issue I didn't think I would run into, but there is always a way around with Alteryx x)

 

I will try to adapt my macro accordingly the next days 

 

Cheers!

 

KevinP
Alteryx Alumni (Retired)

@Hakimipous I did a bit more digging as I was curious as to why the batch file wouldn't recognize the character properly. This appears to be due to the code page setting that the Windows cmd prompt defaults to. In most cases it will default to code page 437 (IBM437) or something similar depending on your OS region. By default we are outputting the bat file as ansi text using the 'ISO 8859-1 Latin I' code page when creating the bat file with the Run Command tool. As these code pages are very different it is causing the characters to be translated incorrect for extended characters. To work around this you can set the code page for the cmd prompt in your batch file. The example batch file below should work for you.

 

chcp 28591
"C:\temp\cpdfTest\cpdf.exe" -encrypt AES "" "test" -i "C:\temp\cpdfTest\Calmîc forecast.pdf" -o "C:\temp\cpdfTest\Calmîc forecast ENCRYPTED.pdf"

 

The 'chcp 28591' command at the beginning will set the correct code page before running the next command allowing for the characters to be interpreted correctly. If you use a different code page for your output file you will need to adjust the number of the code page accordingly. You can find a reference of most common code pages and their identifier number at: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx

 

Also as an additional note if you want to see the current code page setting in the cmd prompt you can run 'chcp' by itself with no arguments to return the code page instead of setting one.

Hakimipous
10 - Fireball

Cheers @KevinP, that's even more simple x)

 

I'll try to adapt by adding the 

chcp 28591

The idea is that my macro should be able to run on different computers in a company, so I will have to check that, but should run! At least it provides  me option to work this around x)

 

I had an intuition telling me it may have something to do with the option set to "ISO 8859-1 Latin " but wasn't really sure about this.

Can I leave it as it is?

 

Thanks again, that's awesome! 

KevinP
Alteryx Alumni (Retired)

@Hakimipous As long as you leave the code page as "ISO 8859-1 Latin I" in the Run Command tool the 'chcp 28591' should work fine for you. If you change it you will need to adjust the number for that command. For example if you change the Run Command's code page setting to UTF-8 you would need to change the batch file command to 'chcp 65001' to accommodate the correct code page.

Hakimipous
10 - Fireball

I see ! 

 

Thanks again for the tip  @KevinP x)

Labels