Create "new text document" as UTF-8

On right click context menu could create "new text document."

https://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/default-utf-8-encoding-for-new-notepad-documents/525f0ae7-121e-4eac-a6c2-cfe6b498712c

I follow above link to make default UTF-8 encoding for new text document, but it's failure on Directory Opus. (12.4 / Win7 x86)

Function NewUTF8file(FileName)
Dim NewFile, UTF8Blob
	If Not DOpus.FSUtil.Exists(Filename) Then
		Set UTF8Blob = Dopus.Create.Blob(&HEF, &HBB, &HBF)
		Set NewFile = DOpus.FSUtil.OpenFile(FileName, "wc", "elevation")
		NewUTF8file = NewFile.Write(UTF8Blob, 0,3)
		NewFile.Close
		Set UTF8Blob = Nothing
		Set NewFile = Nothing
	End If
End Function
newutf8file "d:\test.txt"

test ok


This button does not detect whether the filename is legitimate

<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" textcol="none">
	<label>button</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script VBScript</instruction>
		<instruction>Option Explicit</instruction>
		<instruction>Function OnClick(ByRef clickData)</instruction>
		<instruction>Dim dlg, ret, path</instruction>
		<instruction>Set dlg = DOpus.Dlg</instruction>
		<instruction>dlg.window = DOpus.Listers(0)</instruction>
		<instruction>dlg.message = &quot;File Name&quot;</instruction>
		<instruction>dlg.title = &quot;new text document as UTF-8&quot;</instruction>
		<instruction>dlg.buttons = &quot;OK|Cancel&quot;</instruction>
		<instruction>dlg.icon = &quot;question&quot;</instruction>
		<instruction>dlg.defvalue = &quot;New UTF-8 Text Document.txt&quot;</instruction>
		<instruction>dlg.max = 128  &apos; enable the text field</instruction>
		<instruction>&apos; Show the dialog and print the results to the script log</instruction>
		<instruction>ret = dlg.Show</instruction>
		<instruction>path = IIf(Right(clickData.func.sourcetab.Path, 1) = &quot;\&quot;, clickData.func.sourcetab.Path, clickData.func.sourcetab.Path &amp; &quot;\&quot;)</instruction>
		<instruction>If ret then</instruction>
		<instruction>	If Len(dlg.input) Then </instruction>
		<instruction>		NewUTF8File Path &amp; dlg.input</instruction>
		<instruction>	Else</instruction>
		<instruction>		NewUTF8File Path &amp; dlg.defvalue</instruction>
		<instruction>	End If</instruction>
		<instruction>End If		</instruction>
		<instruction>End Function</instruction>
		<instruction />
		<instruction>Function IIf(ByVal Expression, ByVal TruePart, ByVal FalsePart)</instruction>
		<instruction>    If Expression Then IIf = TruePart Else IIf = FalsePart</instruction>
		<instruction>End Function</instruction>
		<instruction />
		<instruction>Function NewUTF8File(FileName)</instruction>
		<instruction>Dim NewFile, UTF8Blob</instruction>
		<instruction>	If Not DOpus.FSUtil.Exists(Filename) Then</instruction>
		<instruction>		Set UTF8Blob = Dopus.Create.Blob(&amp;HEF, &amp;HBB, &amp;HBF)</instruction>
		<instruction>		Set NewFile = DOpus.FSUtil.OpenFile(FileName, &quot;wc&quot;, &quot;elevation&quot;)</instruction>
		<instruction>		NewUTF8file = NewFile.Write(UTF8Blob, 0,3)</instruction>
		<instruction>		NewFile.Close</instruction>
		<instruction>		Set UTF8Blob = Nothing</instruction>
		<instruction>		Set NewFile = Nothing</instruction>
		<instruction>	End If</instruction>
		<instruction>End Function</instruction>
	</function>
</button>