Cannot Dechiper ISO encoded string

D

Dudely

I pull a text string off a web page, that contains some random text.
From time to time, the string will contain a mixture of ASCII and ISO
encoded characters. Sample below.

I'm unable to get any function to recognize the string.

I'm using VBA 6.0 with Excel 2000

Example code:

Subject= "Auction"

Subject = Replace(Subject, "B", "A")

I've also tried every other character that should be in that string.

The replacement never takes place, the string is unmodified. I've
also tried searching for just "&#" but it never finds that either.
I've tried using InStr as well but that fails to find a match too.
The goal is of course to dechiper the (random) string into it's ASCII
equivalent (so that it can be read by a human).

Any help?

Thank you in advance

- Dudely
 
K

Karl E. Peterson

Dudely said:
Subject= "Auction"

Subject = Replace(Subject, "B", "A")

I've also tried every other character that should be in that string.

Ummmm, there isn't an occurance of "B" in that string, is there?

OTOH, this seems to work just fine:

?Replace("Auction", "A", "A")

What you'll need to do is write a little parser, that takes characters one at a
time, recognizing the "&#" sequence as the beginning of "something special" and
terminating said something when a ";" is encountered. You'd then use the
intervening value with the Chr$() function to generate the intended character.

Or, you could get *really* brute-force, and just iterate the allowable range:

Public Function Decode(ByVal Coded As String) As String
Dim i As Long
For i = 32 To 127
Coded = Replace(Coded, "&#" & CStr(i) & ";", Chr$(i))
Next i
Decode = Coded
End Function

?decode("Auction")
Auction

Looks "easy" but don't let that deceive you! That's a very expensive routine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top