user1514213
user1514213

Reputation:

Convert word special characters in VBS

So, some users have decided to paste word documents into the app I work on. As a result we have the likes of this â–¼ in the database, this should be a black downward triangle like this ▼

Now the app uses a .vbs file to get the data and display it to a classic asp page, the problem is, if I do a replace looking for â–¼ the vbs has already converted it to a ▼ and of course it never finds it, so i just end up with â–¼ being displayed asp page.

so even though i wrote this

strRet = replace(strRet, "â–¼", "▼")

when I debug it looks like this

strRet = replace(strRet, "▼", "▼")

Does anyone know how I can get vbs to look for the actual string of characters

Upvotes: 2

Views: 396

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38745

Use AscW() and ChrW() to build the target string for the Replace() call:

>> s = "â–¼"
>> WScript.Echo s, AscW(Mid(s, 1, 1)), AscW(Mid(s, 2, 1)), AscW(Mid(s, 3, 1))
>>
â–¼ 226 8211 188
>> WScript.Echo Replace(s, ChrW(226) & ChrW(8211) & ChrW(188), ChrW(9660))
>>
▼
>>

Upvotes: 2

Related Questions