<?xml version="1.0" encoding="UTF-8"?>
<rename_preset case="none" group="转换" ignoreext="yes" script="yes" type="normal" version="13">
	<from>*</from>
	<to>*</to>
	<script>@script jscript
// EncodingConvert
// Authors: @Chaoses-Ib, @laoqiuqiu
// Version: 220619.2
// Homepage: https://github.com/Chaoses-Ib/IbDOpusScripts
// Use in command:
// Rename PRESET=&quot;EncodingConvert&quot; SCRIPTARG srcEncoding:1 dstEncoding:3
var encodings = [&apos;utf-8&apos;, &apos;gbk&apos;, &apos;big5&apos;, &apos;shift-jis&apos;, &apos;euc-kr&apos;];
function OnGetNewName(getNewNameData)
{
    return encodingConvert(encodings[getNewNameData.custom.srcEncoding], encodings[getNewNameData.custom.dstEncoding], getNewNameData.newname);
}
function OnGetCustomFields(getFieldData)
{
    // Default: gbk, shift-jis
    srcCombo = DOpus.Create.Vector(1, DOpus.strings.Get(&apos;utf-8&apos;), DOpus.strings.Get(&apos;gbk&apos;), DOpus.strings.Get(&apos;big5&apos;), DOpus.strings.Get(&apos;shift-jis&apos;), DOpus.strings.Get(&apos;euc-kr&apos;));
    getFieldData.fields.srcEncoding = srcCombo;
    getFieldData.field_labels(&apos;srcEncoding&apos;) = DOpus.strings.Get(&apos;srcEncoding&apos;);
    
    dstCombo = DOpus.Create().Vector(srcCombo);
    dstCombo(0) = 3;
    getFieldData.fields.dstEncoding = dstCombo;
    getFieldData.field_labels(&apos;dstEncoding&apos;) = DOpus.strings.Get(&apos;dstEncoding&apos;);
}
function encodingConvert(srcEncoding, dstEncoding, string) {
    // Encodings: https://docs.microsoft.com/en-us/previous-versions/exchange-server/exchange-10/ms526296(v=exchg.10)
    var stream = new ActiveXObject(&apos;Adodb.Stream&apos;);
    stream.Open();
    stream.Charset = srcEncoding;
    stream.WriteText(string);
    stream.Position = 0;
    stream.Charset = dstEncoding;
    var result = stream.ReadText();
    stream.Close();
    return result;
}
==SCRIPT RESOURCES
&lt;resources&gt;
    &lt;resource type=&quot;strings&quot;&gt;
        &lt;strings lang=&quot;english&quot;&gt;
            &lt;string id=&quot;srcEncoding&quot; text=&quot;Source encoding&quot; /&gt;
            &lt;string id=&quot;dstEncoding&quot; text=&quot;Destination encoding&quot; /&gt;
            &lt;string id=&quot;utf-8&quot; text=&quot;UTF-8&quot; /&gt;
            &lt;string id=&quot;gbk&quot; text=&quot;GBK (Simplified Chinese)&quot; /&gt;
            &lt;string id=&quot;big5&quot; text=&quot;Big5 (Traditional Chinese)&quot; /&gt;
            &lt;string id=&quot;shift-jis&quot; text=&quot;Shift-JIS (Japanese)&quot; /&gt;
            &lt;string id=&quot;euc-kr&quot; text=&quot;EUC-KR (Korean)&quot; /&gt;
        &lt;/strings&gt;
        &lt;strings lang=&quot;chs&quot;&gt;
            &lt;string id=&quot;srcEncoding&quot; text=&quot;源编码&quot; /&gt;
            &lt;string id=&quot;dstEncoding&quot; text=&quot;目标编码&quot; /&gt;
            &lt;string id=&quot;utf-8&quot; text=&quot;UTF-8&quot; /&gt;
            &lt;string id=&quot;gbk&quot; text=&quot;GBK（简体中文）&quot; /&gt;
            &lt;string id=&quot;big5&quot; text=&quot;Big5（繁体中文）&quot; /&gt;
            &lt;string id=&quot;shift-jis&quot; text=&quot;Shift-JIS（日语）&quot; /&gt;
            &lt;string id=&quot;euc-kr&quot; text=&quot;EUC-KR（韩语）&quot; /&gt;
        &lt;/strings&gt;
    &lt;/resource&gt;
&lt;/resources&gt;</script>
</rename_preset>
