How can write Unicode Bangla in .ini file?

The Script:

function OnClick(clickData)

{
var cmd = clickData.func.command;
//cmd.RunCommand('Select *.ico');

cmd.RunCommand('Rename PRESET="FolderIcon"');

	if (clickData.func.sourceTab.selected_files.count != 1) {
		return;
	}

	var selFileName = clickData.func.sourceTab.selected_files(0).name ;
DOpus.output(selFileName)
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var iniPath = fso.BuildPath(clickData.func.sourceTab.path, "desktop.ini");

	if (fso.FileExists(iniPath)){
	    var txtFileMeta = fso.GetFile(iniPath);
		txtFileMeta.Attributes = 0; // Clear Read-Only + Hidden.
	}

	var txtFile = fso.CreateTextFile(iniPath, true);
	txtFile.WriteLine("[.ShellClassInfo]");
	txtFile.WriteLine("IconResource=" + selFileName + ",0");
	txtFile.Close();

    var txtFileMeta = fso.GetFile(iniPath);
	txtFileMeta.Attributes = 3; // Read-Only + Hidden.

	var currentPath =  fso.GetFolder(clickData.func.sourceTab.path);
	currentPath.Attributes = 1; // Read-Only.


	var icoFileName = clickData.func.sourceTab.selected_files(0);  
  	var fso = new ActiveXObject("Scripting.FileSystemObject");
  	var icoFileMeta = fso.GetFile(icoFileName);
  	icoFileMeta.Attributes =  3; //  Hidden.
}

This Script Works fine, no problem, without this line

var cmd = clickData.func.command;
//cmd.RunCommand('Select *.ico');

cmd.RunCommand('Rename PRESET="FolderIcon"');

with the Rename Preset the ico file has been renamed with Unicode Bangla Characters āĻ…āĻ¨ā§‡āĻ• āĻ¸ā§āĻŦāĻĒā§āĻ¨ āĻ›āĻŋāĻ˛ āĻ¤ā§‹āĻŽāĻžāĻ•ā§‡ āĻ¨āĻŋā§Ÿā§‡. āĻļāĻŋāĻ˛ā§āĻĒā§€. āĻŽāĻ¨āĻŋāĻ° āĻ–āĻžāĻ¨ FolderIcon
Then the error appears. The Unicode Bangla Characters can not be written in the ini file. Is there any way to fix that. Thanks

See the documentation on the object and method you are using to open the text file, and how to open it in Unicode mode:

Or, in case Microsoft break their URLs like they often do:

1 Like
var txtFile = fso.CreateTextFile(iniPath, true, true);

Thanks Leo for the Help. the first true for Overwrite Parameter so I need a 2nd true for the Unicode Parameter