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
+9.1k Golang : Build and compile multiple source files
+15.8k Golang : ROT47 (Caesar cipher by 47 characters) example
+4.2k Javascript : Empty an array example
+5.7k Golang : Shortening import identifier
+14k Golang : concatenate(combine) strings
+14k Golang : How to determine if a year is leap year?
+9.5k Golang : Scramble and unscramble text message by randomly replacing words
+19.4k Golang : Get RGBA values of each image pixel
+17.5k Golang : Get future or past hours, minutes or seconds
+6.3k Golang : Extract sub-strings
+11.2k Golang : Fix go.exe is not compatible with the version of Windows you're running
+15.9k Golang : Get current time from the Internet time server(ntp) example