Golang encoding/ascii85.Encode function example
package encoding/ascii85
Encode encodes input source(2nd param) into at most MaxEncodedLen(len(src)) bytes of output(1st param), returning the actual number of bytes written.
The encoding handles 4-byte chunks, using a special encoding for the last fragment, so Encode is not appropriate for use on individual blocks of a large data stream. Use NewEncoder() instead.
Often, ascii85-encoded data is wrapped in <~ and ~> symbols. Encode does not add these.
Golang encoding/ascii85.Encode function usage example
package main
import (
"encoding/ascii85"
"fmt"
)
func main() {
str := []byte("Man is distinguished, not only by his reason, but by this singular passion from")
buffer := make([]byte, ascii85.MaxEncodedLen(len(str)))
encodedbytes := ascii85.Encode(buffer, str)
fmt.Println("Bytes written : ", encodedbytes)
fmt.Println(string(buffer))
}
Output :
Bytes written : 99
9jqo^BlbD-BleB1DJ++F(f,q/0JhKF
Cj@.4Gp$d7F!,L7@<6@)/0JDEF<G%<+EV:2F!,O<DJ+ .@<*K0@<6L(Df-\0Ec5dp
Reference :
See also : Golang encoding/ascii85.Decode function example
Advertisement
Something interesting
Tutorials
+18k Golang : Put UTF8 text on OpenCV video capture image frame
+8.2k Your page has meta tags in the body instead of the head
+9.4k Golang : How to extract video or image files from html source code
+18.9k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+30.1k Golang : How to verify uploaded file is image or allowed file types
+8k Golang : How To Use Panic and Recover
+5.6k Unix/Linux/MacOSx : Get local IP address
+5.9k nginx : force all pages to be SSL
+13.8k Golang : Human readable time elapsed format such as 5 days ago
+39k Golang : How to read CSV file
+25.2k Golang : Convert uint value to string type
+7.6k Golang : How to execute code at certain day, hour and minute?