Other Software > Developer's Corner
Set a VBS file encoding
Yaron:
Hello,
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
:VBSDynamicBuild
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.
wraith808:
--- 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
From https://stackoverflow.com/questions/5182102/vb6-vbscript-change-file-encoding-to-ansi
Yaron:
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.
wraith808:
So you changed
.Charset = "utf-8"
to what?
Yaron:
I've changed .Charset = "utf-8" to .Charset = "_autodetect"
and then .Charset = "_autodetect" to .Charset = "Windows-1255".
Thanks again.
Navigation
[0] Message Index
[#] Next page
Go to full version