1[manpage_begin base64 n 2.4.2]
2[copyright {2000, Eric Melski}]
3[copyright {2001, Miguel Sofer}]
4[moddesc   {Text encoding & decoding binary data}]
5[titledesc {base64-encode/decode binary data}]
6[category  {Text processing}]
7[require Tcl 8]
8[require base64 [opt 2.4.2]]
9[description]
10[para]
11
12This package provides procedures to encode binary data into base64 and back.
13
14[list_begin definitions]
15
16[call [cmd ::base64::encode] [opt "[option -maxlen] [arg maxlen]"] [opt "[option -wrapchar] [arg wrapchar]"] [arg string]]
17
18Base64 encodes the given binary [arg string] and returns the encoded
19result. Inserts the character [arg wrapchar] every [arg maxlen]
20characters of output. [arg wrapchar] defaults to newline. [arg maxlen]
21defaults to [const 76].
22
23[para]
24
25[emph {Note well}]: If your string is not simple ascii you should fix
26the string encoding before doing base64 encoding. See the examples.
27
28[para]
29
30The command will throw an error for negative values of [arg maxlen],
31or if [arg maxlen] is not an integer number.
32
33
34[call [cmd ::base64::decode] [arg "string"]]
35
36Base64 decodes the given [arg "string"] and returns the binary data.
37The decoder ignores whitespace in the string.
38
39[list_end]
40
41[section {EXAMPLES}]
42
43[example {
44% base64::encode "Hello, world"
45SGVsbG8sIHdvcmxk
46}]
47
48[example {
49% base64::encode [string repeat xyz 20]
50eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6
51eHl6eHl6eHl6
52% base64::encode -wrapchar "" [string repeat xyz 20]
53eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6
54}]
55
56[example {
57# NOTE: base64 encodes BINARY strings.
58% set chemical [encoding convertto utf-8 "C\u2088H\u2081\u2080N\u2084O\u2082"]
59% set encoded [base64::encode $chemical]
60Q+KCiEjigoHigoBO4oKET+KCgg==
61% set caffeine [encoding convertfrom utf-8 [base64::decode $encoded]]
62}]
63
64
65[section {BUGS, IDEAS, FEEDBACK}]
66
67This document, and the package it describes, will undoubtedly contain
68bugs and other problems.
69
70Please report such in the category [emph base64] of the
71[uri {http://sourceforge.net/tracker/?group_id=12883} {Tcllib SF Trackers}].
72
73Please also report any ideas for enhancements you may have for either
74package and/or documentation.
75
76
77[keywords encoding base64]
78[manpage_end]
79