ReneGe
asked on
VBScript : Convert text : "ASCII Codes" to "ISO 8859-1 Characters"
Hi there,
The purpose of this script is to convert some characters within a text file.
The problem here is, for example, once it converted &H88 to &HEA, it will reconvert the same character from &HEA to &HDB.
I need this script to convert a character only once.
(I was wondering if the use of a "regular expression" would be the answer.)
Please provide full code.
Thanks for your help,
Rene
The purpose of this script is to convert some characters within a text file.
The problem here is, for example, once it converted &H88 to &HEA, it will reconvert the same character from &HEA to &HDB.
I need this script to convert a character only once.
(I was wondering if the use of a "regular expression" would be the answer.)
Please provide full code.
Thanks for your help,
Rene
Dim Mystring,MyFile
MyFile=WScript.Arguments(0)
'get file in string
Mystring=Getfile(MyFile)
MyString=replace(MyString,chr(&HB7),chr(&HC0))
MyString=replace(MyString,chr(&H85),chr(&HE0))
MyString=replace(MyString,chr(&HB6),chr(&HC2))
MyString=replace(MyString,chr(&H83),chr(&HE2))
MyString=replace(MyString,chr(&H92),chr(&HC6))
MyString=replace(MyString,chr(&H91),chr(&HE6))
MyString=replace(MyString,chr(&H80),chr(&HC7))
MyString=replace(MyString,chr(&H87),chr(&HE7))
MyString=replace(MyString,chr(&HD4),chr(&HC8))
MyString=replace(MyString,chr(&H8A),chr(&HE8))
MyString=replace(MyString,chr(&H90),chr(&HC9))
MyString=replace(MyString,chr(&H82),chr(&HE9))
MyString=replace(MyString,chr(&HD2),chr(&HCA))
MyString=replace(MyString,chr(&H88),chr(&HEA))
MyString=replace(MyString,chr(&HD3),chr(&HCB))
MyString=replace(MyString,chr(&H89),chr(&HEB))
MyString=replace(MyString,chr(&HD7),chr(&HCE))
MyString=replace(MyString,chr(&H8C),chr(&HEE))
MyString=replace(MyString,chr(&HD8),chr(&HCF))
MyString=replace(MyString,chr(&H8B),chr(&HEF))
MyString=replace(MyString,chr(&HE2),chr(&HD4))
MyString=replace(MyString,chr(&H93),chr(&HF4))
MyString=replace(MyString,chr(&HEB),chr(&HD9))
MyString=replace(MyString,chr(&H97),chr(&HF9))
MyString=replace(MyString,chr(&HEA),chr(&HDB))
MyString=replace(MyString,chr(&H96),chr(&HFB))
MyString=replace(MyString,chr(&H9A),chr(&HDC))
MyString=replace(MyString,chr(&H81),chr(&HFC))
'write result in same file
Dim OutStream, FS
on error resume Next
Set FS = CreateObject("Scripting.FileSystemObject")
Set OutStream = FS.OpenTextFile(MyFile, 2, True)
OutStream.Write MyString
function GetFile(FileName)
If FileName<>"" Then
Dim FS, FileStream
Set FS = CreateObject("Scripting.FileSystemObject")
on error resume Next
Set FileStream = FS.OpenTextFile(FileName)
GetFile = FileStream.ReadAll
End If
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found 2 more to reorder. Tested it and works well.
Thanks Tuyau2poil for writing script.
Thanks B34RDY for helping me resolving the issue.
Cheers,
Rene