Option Explicit Dim objFSO, objTxt, objWShell Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set objTxt = objFSO.OpenTextFile("Henkan_Test.txt", ForAppending, true, -1) Set objWShell = WScript.CreateObject("WScript.Shell") Dim strInput '入力コード Dim strCode '入力コードを配列変数に ' 入力 myInput ' 文字数チェック(253文字まで) If Len(strInput) > 253 Then myNagasugi ' 入力文字をテキストへ書込 objTxt.WriteLine "コード : " & strInput ' 入力コードを配列変数に myHairetu(strInput) ' 配列変数をShift_JIS 文字列に myHenkan "Shift_JIS" ' 配列変数をUnicode 文字列に myHenkan "Unicode " ' 改行 objTxt.WriteBlankLines (1) 'objTxtをクローズしてテキストエディタで開く objTxt.Close objWShell.Run "Henkan_Test.txt" 'オブジェクトを破棄 Set objWShell = Nothing Set objTxt = Nothing Set objFSO = Nothing '********************************************************* '* Sub myInput -- 入力 '********************************************************* Sub myInput strInput = InputBox("変換するカンマ区切りの符号を入力", "文字コードを文字に変換") If IsEmpty(strInput) Then WScript.Quit If strInput = "" Then myInput Else myEcho End If End Sub '********************************************************* '* Sub myEcho -- 入力文字チェック '********************************************************* Sub myEcho Dim intStr, intStrB '文字数、バイト数 intStr = Len(strInput) intStrB = LenB(strInput) If intStr > 253 Then intStr = "254文字 オーバー" If intStrB > 507 Then intStrB = "508バイト オーバー" WScript.Echo " * 変数名 : ", "strInput",vbCrLf, _ " * 値 : ", strInput, vbCrLf, vbCrLf, _ " * 型 : ", TypeName(strInput), vbCrLf, _ " * 文字数 : ", intStr, vbCrLf, _ " * バイト : ", intStrB End Sub '********************************************************* '* Sub myHairetu -- 入力コードを配列変数に '********************************************************* Sub myHairetu(myStr) strCode = split(myStr, ",", -1, 1) End Sub '********************************************************* '* Sub myHenkan(myCode) -- 配列を文字に変換 '********************************************************* Sub myHenkan(myCode) Dim x objTxt.Write "文字列(" & myCode & ")" & " : " For Each x in (strCode) On Error Resume Next x = CLng("&H" & x) If myCode = "Shift_JIS" Then x = Chr(x) Else x = ChrW(x) End If objTxt.Write x On Error Goto 0 Next objTxt.WriteBlankLines (1) End Sub '********************************************************* '* Sub myNagasugi -- 254文字以上なら中断 '********************************************************* Sub myNagasugi WScript.Echo "入力データが長すぎます...", vbCrLf, _ "253文字以下に分割してください。" objTxt.Close Set objWShell = Nothing Set objTxt = Nothing Set objFSO = Nothing WScript.Quit End Sub