Classic ASP
Classic ASP
Append Encoded Binary Data to StringBuilder
Demonstrates how to append encoded binary data to the contenets of a StringBuilder.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
set bd = Server.CreateObject("Chilkat.BinData")
success = bd.LoadFile("qa_data/jpg/starfish.jpg")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( "Failed to load file.") & "</pre>"
Response.End
End If
' For example, let's say we want construct simple JSON containing the base64 representation of the above JPG file.
set sb = Server.CreateObject("Chilkat.StringBuilder")
success = sb.Append("{ ""jpg"": """)
' GetEncodedSb appends the enocded representation of the binary data to the StringBuiler passed in the 2nd arg.
success = bd.GetEncodedSb("base64",sb)
success = sb.Append(""" }")
Response.Write "<pre>" & Server.HTMLEncode( sb.GetAsString()) & "</pre>"
' Output looks like this:
' { "jpg": "/9j/4AAQSkZJRgABAg...rcQ+vo//2Q==" }
%>
</body>
</html>