I am running a function similar to the one offered by AlexanderBB that follows but it runs very slow when the Base64 string gets large at the point where ADODB.Stream .ReadText is set as the function return.
Function DecodeBase64(b64$)
Dim b
With CreateObject("Microsoft.XMLDOM").createElement("b64")
.DataType = "bin.base64": .Text = b64
b = .nodeTypedValue
End With
With CreateObject("ADODB.Stream")
.Open: .Type = 1: .Write b: .Position = 0: .Type = 2: .Charset = "utf-8"
DecodeBase64 = .ReadText
.Close
End With
End Function
I have read that this can happen when the ADODB.Stream gets large and a work around can be to process the stream using a line loop something similar to the following where -2 denotes the line
do while o.EOF --o is the adoStream
s = s & o.ReadText -2 --s is a string return
loop
DecodeBase64 = s
Now this does not work in the following code because of the binary flow, so I wondered if anyone had any idea how I could refactor the code to process the stream into smaller chunks so that the ADODB.Stream does not flip out with large volume of data. Please note that the UTF8 part is important hence the use of the ADODB.Stream in the first place.
Function DecodeBase64(b64$)
Dim b
With CreateObject("Microsoft.XMLDOM").createElement("b64")
.DataType = "bin.base64": .Text = b64
b = .nodeTypedValue
End With
With CreateObject("ADODB.Stream")
.Open: .Type = 1: .Write b: .Position = 0: .Type = 2: .Charset = "utf-8"
DecodeBase64 = .ReadText
.Close
End With
End Function
I have read that this can happen when the ADODB.Stream gets large and a work around can be to process the stream using a line loop something similar to the following where -2 denotes the line
do while o.EOF --o is the adoStream
s = s & o.ReadText -2 --s is a string return
loop
DecodeBase64 = s
Now this does not work in the following code because of the binary flow, so I wondered if anyone had any idea how I could refactor the code to process the stream into smaller chunks so that the ADODB.Stream does not flip out with large volume of data. Please note that the UTF8 part is important hence the use of the ADODB.Stream in the first place.