ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Set a VBS file encoding

(1/2) > >>


I use the following code in a BAT file to open a folder and select a file in an existing Windows Explorer window (QTTabBar installed).

--- ---start "" %1

SET TempVBSFile=%temp%\~tmpSendKeysTemp.vbs

ECHO Set tSK = CreateObject("WScript.Shell") >> "%TempVBSFile%"
ECHO WScript.Sleep 200 >> "%TempVBSFile%"
ECHO tSK.SendKeys "^q%~2" >> "%TempVBSFile%"

CSCRIPT //NoLogo "%TempVBSFile%"

DEL /F /Q "%TempVBSFile%"
How can I change the temp VBS file encoding from the BAT file?

I'd appreciate your help.


--- Code: Visual Basic ---Option Explicit Private Const adReadAll = -1Private Const adSaveCreateOverWrite = 2Private Const adTypeBinary = 1Private Const adTypeText = 2Private Const adWriteChar = 0 Private Sub UTF8toANSI(ByVal UTF8FName, ByVal ANSIFName)    Dim strText     With CreateObject("ADODB.Stream")        .Open        .Type = adTypeBinary        .LoadFromFile UTF8FName        .Type = adTypeText        .Charset = "utf-8"        strText = .ReadText(adReadAll)        .Position = 0        .SetEOS        .Charset = "_autodetect" 'Use current ANSI codepage.        .WriteText strText, adWriteChar        .SaveToFile ANSIFName, adSaveCreateOverWrite        .Close    End WithEnd Sub UTF8toANSI "UTF8-wBOM.txt", "ANSI1.txt"UTF8toANSI "UTF8-noBOM.txt", "ANSI2.txt"MsgBox "Complete!", vbOKOnly, WScript.ScriptName

Hello wraith808,

Thanks for replying. I appreciate it.

I've managed to convert from ANSI to UTF-8. Trying to convert from ANSI to Windows-1255 (Hebrew) does not work.
Any idea?

Best regards.

So you changed

.Charset = "utf-8"

to what?

I've changed .Charset = "utf-8" to .Charset = "_autodetect"
and then .Charset = "_autodetect" to .Charset = "Windows-1255".

Thanks again.


[0] Message Index

[#] Next page

Go to full version