Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Const fbAuto = 0
- Const fbNoBOM = 1
- Const fbBOM = 2
- Const feAuto = 0
- Const feANSI = 1
- Const feUTF8 = 2
- Const feUTF16 = 3
- Const ibAuto = 0
- Const ibDontInvertBytes = 1
- Const ibInvertBytes = 2
- Dim ajpFSO
- Set ajpFSO = CreateObject("FileIOSupport0102.ajpFSO")
- '====================================================================
- Dim InFileName
- Dim OutFileName
- Select Case WScript.Arguments.Count
- Case 1
- InFileName = WScript.Arguments(0)
- OutFileName = ""
- Case 2
- InFileName = WScript.Arguments(0)
- OutFileName = WScript.Arguments(1)
- Case Else
- WScript.Echo "Uage: OptimizeRussianText[.VBS] InputFileName [OutputFileName]"
- WScript.Quit
- End Select
- '====================================================================
- Dim TXT
- On Error Resume Next
- TXT = ajpFSO.GetFile2(InFileName, True)
- If Err.Number <> 0 Then
- WScript.Echo "Can't read file. Error " & Err.Number & ": " & Err.Description
- WScript.Quit
- End If
- '====================================================================
- Dim Chars
- Dim TMP
- Chars = Array("Ё", "Е", "Й", "И", "Щ", "Ш", "Л", "П", _
- "Ы", "Ь", "Б", "Ь", "В", "Ь", "Ю", "О", _
- "Ъ", "Ь", "Н", "Ч", "П", "Г")
- For TMP = LBound(Chars) To UBound(Chars) - 1 Step 2
- TXT = Replace(TXT, UCase(Chars(TMP)), UCase(Chars(TMP + 1)), vbTextCompare)
- TXT = Replace(TXT, LCase(Chars(TMP)), LCase(Chars(TMP + 1)), vbTextCompare)
- Next
- '====================================================================
- If OutFileName = "" Then
- WScript.Echo TXT
- WScript.Quit
- End If
- '====================================================================
- ajpFSO.PutFile2 OutFileName, TXT, True, feUTF8, fbBOM
- If Err.Number <> 0 Then
- WScript.Echo "Can't write file. Error " & Err.Number & ": " & Err.Description
- WScript.Quit
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement