rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: newbie on March 23, 2021, 05:18:36 PM

Title: passing utf-8 characters in hfs.tpl function
Post by: newbie on March 23, 2021, 05:18:36 PM
Hi,
I created a simple function like below which exec's an external application.
It takes 2 utf-8 arguments. I've noticed that the args show up with ???? chars for the utf-8 characters in the Powershell script.
I've tried changing the active code page in the PS1 script by adding chcp 65001 and Input/Output encoding to UTF-8, but makes no difference.

However, if I change the active code page for the machine by changing this registry entry and then RESTARTING windows..
Code: [Select]
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP 65001it sends utf-8 characters into the PS1 script.

Is there anyway to do this, without changing the active page of the machine & restarting?


Code: [Select]
[ajax.foo|public|no log]
{.check session.}
{.set|x|{.postvar|var1.}.}
{.set|y|{.postvar|var2.}.}
{.exec|powershell.exe -F foo.ps1 "{.^x.}" "{.^y.}"|out=#output.}
{.^#output.}
Title: Re: passing utf-8 characters in hfs.tpl function
Post by: danny on March 25, 2021, 10:22:28 AM
I wonder if one of HFS versions will do a little differently? 
K https://sourceforge.net/projects/hfs/files/HFS/2.3k/
M http://rejetto.com/hfs/?f=dl
RC7 http://rejetto.com/forum/index.php?topic=13060.msg1064012#msg1064012

Other things to explore
powershell Get-Content .\test.txt | Set-Content -Encoding utf8 test-utf8.txt
https://www.powershelladmin.com/wiki/Convert_from_most_encodings_to_utf8_with_powershell
Title: Re: passing utf-8 characters in hfs.tpl function
Post by: newbie on March 25, 2021, 03:11:02 PM
Looking at the 2.4.0 rc07 src:
utillib.pas Line 1238:
Code: [Select]
result:=(cmd > '') and (32 < shellexecute(0, 'open', pchar(cmd), pchar(pars), NIL, showCmd)
Should this be:
Code: [Select]
result:=(cmd > '') and (32 < shellexecuteW(0, 'open', pwidechar(cmd), pwidechar(pars), NIL, showCmd)
Title: Re: passing utf-8 characters in hfs.tpl function
Post by: newbie on March 26, 2021, 08:48:28 PM
I compiled 2.4.0rc07 and I can confirm that w/ the below change, I'm seeing utf-8 values in my arguments inside the Powershell script.

2.4.0 rc07 src:
utillib.pas Line 1238:
Code: [Select]
result:=(cmd > '') and (32 < shellexecuteW(0, 'open', pwidechar(cmd), pwidechar(pars), NIL, showCmd)