''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Author : 투덜ⓔ
'Title : 문자열변환+개행
'Date : 2011.01
'설명 : 지정한 문자열을 기준으로 개행을 하고, '%'로 시작하는 16진수 값을 변환하여 문자,한글로 변환
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'사용법 : 1. Acroedit의 사용자 도구 설정에서 사용자 도구를 하나 추가합니다.
' - 메뉴이름에 에 알아서입력 : 디코딩변환
' - 명령 에 다음값입력 : C:\WINDOWS\system32\cscript.exe
' - 인자 에 다음값입력 : /nologo "C:\Program Files\AcroSoft\AcroEdit\디코딩변환.vbs" "%SELBLOCK%"
' 2. Acroedit 편집창에서 사용자도구 실행하면 출력창에 결과를 출력.
'<테스트><테스트> %3C%C5%D7%BD%BA%C6%AE%3E%3C%C5%D7%BD%BA%C6%AE%3E
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
On Error Resume Next
Dim sText
Set objArgs = WScript.Arguments
if objArgs.Count > 0 then
sText=TRIM(objArgs(0)) ' 마우스로 드래그시 파일명 전달
if len(sText)=0 then
WScript.echo "=== 입력된 문자가 없습니다. ===[" & sText & "]"
WScript.Quit(0)
end if
else
WScript.echo "=== 입력된 인자가 없습니다. ==="
WScript.Quit(0)
end if
log("입력문자열 [" & sText & "]")
Do While InStr(sText,"%") > 0
iPos = InStr(sText,"%")
sFind = Mid(sText,iPos,3)
iDec1 = HexToDec(Mid(sFind,2,2))
log("iPos ["&iPos&"] sFind ["&sFind&"] iDec1["&CStr(iDec1)&"]")
If iDec1 < 129 Then
ToStr = chr(iDec1)
Else
sFind = Mid(sText,iPos,6)
iDec2 = HexToDec(Mid(sFind,5,2))
ToStr = chr("&h" & Mid(sFind,2,2) & Mid(sFind,5,2))
End If
log("sFind["&sFind&"] ToStr["&ToStr&"]")
sText = Replace(sText,sFind,ToStr)
Loop
sText = Replace(sText,"><",">"&chr(10)&"<")
log("=== 변환완료 ===")
WScript.echo sText
WScript.Quit(0)
Function log(str)
'WScript.echo str
End Function
Function HexToDec(str)
HexToDec = 0
For i = 1 To Len(str)
iDec = isHex(Mid(str,Len(str)-i+1,1))
HexToDec = HexToDec + iDec * 16 ^ ( i-1 )
log("=== HexToDec i ["&i&"] iDec ["&CStr(iDec)&"] HexToDec ["&CStr(HexToDec)&"]")
Next
log("=== HexToDec End result["&CStr(HexToDec)&"]")
End Function
Function isHex(str)
log("=== isHex Start str["&str&"]")
isHex = 0
If Asc(str) >= 48 AND Asc(str) <= 57 Then '0~1 숫자이면
isHex = CInt(str)
ElseIf Asc(str) >= 65 AND Asc(str) <= 70 Then 'A~F 문자이면
isHex = Asc(str)-55
Else
isHex = 0
End If
log("=== isHex End result["&CStr(isHex)&"]")
End Function