Plugin actions: KMPARAMs and UTF-8 international glyphs

( Apologies there for the reckless misuse of German and Greek etc characters )

For refce, the .systemAttribute() version, which works fine within its Anglo-Saxon limits, is:

#!/bin/bash
osascript -l JavaScript <<JXA_END 2>/dev/null
(function () {
    var a = Application.currentApplication(),
	    sa = (a.includeStandardAdditions = true, a); 

    return encodeURIComponent(
        sa.systemAttribute('KMPARAM_Text_to_encode')
    );
})();
JXA_END

Link to plugin

FWIW, a purely JavaScript version, outside the Bash context, works fine:

var strHan = "汉子",
	strCode = encodeURIComponent(strHan),
	strDecode = decodeURIComponent(strCode);
	
[strCode, strDecode]
["%E6%B1%89%E5%AD%90", "汉子"]
1 Like