1base64(n)            Text encoding & decoding binary data            base64(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       base64 - base64-encode/decode binary data
9

SYNOPSIS

11       package require Tcl  8
12
13       package require base64  ?2.4?
14
15       ::base64::encode ?-maxlen maxlen? ?-wrapchar wrapchar? string
16
17       ::base64::decode string
18
19_________________________________________________________________
20

DESCRIPTION

22       This  package provides procedures to encode binary data into base64 and
23       back.
24
25       ::base64::encode ?-maxlen maxlen? ?-wrapchar wrapchar? string
26              Base64 encodes the given binary string and returns  the  encoded
27              result.  Inserts  the character wrapchar every maxlen characters
28              of output. wrapchar defaults to newline. maxlen defaults to 60.
29
30              Note well: If your string is not simple ascii you should fix the
31              string encoding before doing base64 encoding. See the examples.
32
33              The  command  will throw an error for negative values of maxlen,
34              or if maxlen is not an integer number.
35
36       ::base64::decode string
37              Base64 decodes the given string and  returns  the  binary  data.
38              The decoder ignores whitespace in the string.
39

EXAMPLES

41       % base64::encode "Hello, world"
42       SGVsbG8sIHdvcmxk
43
44
45       % base64::encode [string repeat xyz 20]
46       eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6
47       eHl6eHl6eHl6
48       % base64::encode -wrapchar "" [string repeat xyz 20]
49       eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6eHl6
50
51
52       # NOTE: base64 encodes BINARY strings.
53       % set chemical [encoding convertto utf-8 "C\u2088H\u2081\u2080N\u2084O\u2082"]
54       % set encoded [base64::encode $chemical]
55       Q+KCiEjigoHigoBO4oKET+KCgg==
56       % set caffeine [encoding convertfrom utf-8 [base64::decode $encoded]]
57
58

BUGS, IDEAS, FEEDBACK

60       This  document,  and the package it describes, will undoubtedly contain
61       bugs and other problems.  Please report such in the category base64  of
62       the          Tcllib         SF         Trackers         [http://source
63       forge.net/tracker/?group_id=12883].  Please also report any  ideas  for
64       enhancements you may have for either package and/or documentation.
65

KEYWORDS

67       base64, encoding
68
70       Copyright (c) 2000, Eric Melski
71       Copyright (c) 2001, Miguel Sofer
72
73
74
75
76base64                                2.4                            base64(n)
Impressum