If I replace
var textDecode = ST.Decode(bytes, "utf-8");
with
var textDecode = ST.Decode(bytes, "65001");
it will throw an error, am I understanding this wrong?
Blockquote
If format is not specified the default is auto . Otherwise, format must be set to one of the above keywords or a valid code-page name (e.g. "gb2312" , "utf-8" ), or a Windows code-page ID (e.g. 936 , 65001 ). The source will be decoded using the specified code-page and a string is returned.
function OnClick(clickData) {
var tab = clickData.func.sourcetab;
var fsu = DOpus.FSUtil();
var ST = DOpus.Create.StringTools();
for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
var file = e.item();
var filePath = file.realpath;
if (fsu.Exists(filePath)) {
var openText = fsu.OpenFile(filePath, "r");
var bytes = openText.Read();
openText.Close();
var textDecode = ST.Decode(bytes, "utf-8");
var textContent = ST.Truncate(textDecode, 2048, 0);
DOpus.Output(textContent);
}
}
}