@@ -26,22 +26,22 @@ static CHARS: [char, ..64] = [
26
26
'0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '+' , '/'
27
27
] ;
28
28
29
- /**
30
- * Turn a vector of `u8` bytes into a string representing them in base64.
31
- *
32
- * *Example*:
33
- *
34
- * ~~~~
35
- * extern mod std;
36
- * use std::base64::ToBase64;
37
- *
38
- * fn main () {
39
- * let str = [52,32].to_base64();
40
- * println(fmt!("%s", str));
41
- * }
42
- * ~~~~
43
- */
44
29
impl < ' self > ToBase64 for & ' self [ u8 ] {
30
+ /**
31
+ * Turn a vector of `u8` bytes into a string representing them in base64.
32
+ *
33
+ * *Example*:
34
+ *
35
+ * ~~~~
36
+ * extern mod std;
37
+ * use std::base64::ToBase64;
38
+ *
39
+ * fn main () {
40
+ * let str = [52,32].to_base64();
41
+ * println(fmt!("%s", str));
42
+ * }
43
+ * ~~~~
44
+ */
45
45
fn to_base64( & self ) -> ~str {
46
46
let mut s = ~"";
47
47
unsafe {
@@ -90,24 +90,24 @@ impl<'self> ToBase64 for &'self [u8] {
90
90
}
91
91
}
92
92
93
- /**
94
- * Convert any string (literal, `@`, `&`, `~`) to base64 encoding.
95
- *
96
- *
97
- * *Example*:
98
- *
99
- * ~~~~
100
- * extern mod std;
101
- * use std::base64::ToBase64;
102
- *
103
- * fn main () {
104
- * let str = " Hello , World ".to_base64();
105
- * println(fmt!(" %s",str));
106
- * }
107
- * ~~~~
108
- *
109
- */
110
93
impl<'self> ToBase64 for &'self str {
94
+ /**
95
+ * Convert any string (literal, `@`, `&`, `~`) to base64 encoding.
96
+ *
97
+ *
98
+ * *Example*:
99
+ *
100
+ * ~~~~
101
+ * extern mod std;
102
+ * use std::base64::ToBase64;
103
+ *
104
+ * fn main () {
105
+ * let str = " Hello , World ".to_base64();
106
+ * println(fmt!(" %s",str));
107
+ * }
108
+ * ~~~~
109
+ *
110
+ */
111
111
fn to_base64(&self) -> ~str {
112
112
str::to_bytes(*self).to_base64()
113
113
}
@@ -117,26 +117,26 @@ pub trait FromBase64 {
117
117
fn from_base64(&self) -> ~[u8];
118
118
}
119
119
120
- /**
121
- * Turn a vector of `u8`s representing characters
122
- * encoding byte values in base64 into the vector of `u8` byte values.
123
- *
124
- * *Example*:
125
- *
126
- * ~~~~
127
- * extern mod std;
128
- * use std::base64::ToBase64;
129
- * use std::base64::FromBase64;
130
- *
131
- * fn main () {
132
- * let str = [52,32].to_base64();
133
- * println(fmt!(" %s", str));
134
- * let bytes = str.from_base64();
135
- * println(fmt!(" %?",bytes));
136
- * }
137
- * ~~~~
138
- */
139
120
impl FromBase64 for ~[u8] {
121
+ /**
122
+ * Turn a vector of `u8`s representing characters
123
+ * encoding byte values in base64 into the vector of `u8` byte values.
124
+ *
125
+ * *Example*:
126
+ *
127
+ * ~~~~
128
+ * extern mod std;
129
+ * use std::base64::ToBase64;
130
+ * use std::base64::FromBase64;
131
+ *
132
+ * fn main () {
133
+ * let str = [52,32].to_base64();
134
+ * println(fmt!(" %s", str));
135
+ * let bytes = str.from_base64();
136
+ * println(fmt!(" %?",bytes));
137
+ * }
138
+ * ~~~~
139
+ */
140
140
fn from_base64(&self) -> ~[u8] {
141
141
if self.len() % 4u != 0u { fail!(~" invalid base64 length"); }
142
142
@@ -198,35 +198,35 @@ impl FromBase64 for ~[u8] {
198
198
}
199
199
}
200
200
201
- /**
202
- * Convert any string (literal, `@`, `&`, `~`)
203
- * that contains a base64 encoded value, to the byte values it encodes.
204
- *
205
- * You can use the `from_bytes` function in `core::str`
206
- * to turn a `[u8]` into a string with characters corresponding to those values.
207
- *
208
- * *Example*:
209
- *
210
- * This is an example of going from a string literal to the base64 encoding
211
- * and back to the same string.
212
- *
213
- * ~~~~
214
- * extern mod std;
215
- * use std::base64::ToBase64;
216
- * use std::base64::FromBase64;
217
- * use core::str;
218
- *
219
- * fn main () {
220
- * let hello_str = " Hello , World ".to_base64();
221
- * println(fmt!(" %s",hello_str));
222
- * let bytes = hello_str.from_base64();
223
- * println(fmt!(" %?",bytes));
224
- * let result_str = str::from_bytes(bytes);
225
- * println(fmt!(" %s",result_str));
226
- * }
227
- * ~~~~
228
- */
229
201
impl FromBase64 for ~str {
202
+ /**
203
+ * Convert any string (literal, `@`, `&`, `~`)
204
+ * that contains a base64 encoded value, to the byte values it encodes.
205
+ *
206
+ * You can use the `from_bytes` function in `core::str`
207
+ * to turn a `[u8]` into a string with characters corresponding to those values.
208
+ *
209
+ * *Example*:
210
+ *
211
+ * This is an example of going from a string literal to the base64 encoding
212
+ * and back to the same string.
213
+ *
214
+ * ~~~~
215
+ * extern mod std;
216
+ * use std::base64::ToBase64;
217
+ * use std::base64::FromBase64;
218
+ * use core::str;
219
+ *
220
+ * fn main () {
221
+ * let hello_str = " Hello , World ".to_base64();
222
+ * println(fmt!(" %s",hello_str));
223
+ * let bytes = hello_str.from_base64();
224
+ * println(fmt!(" %?",bytes));
225
+ * let result_str = str::from_bytes(bytes);
226
+ * println(fmt!(" %s",result_str));
227
+ * }
228
+ * ~~~~
229
+ */
230
230
fn from_base64(&self) -> ~[u8] {
231
231
str::to_bytes(*self).from_base64()
232
232
}
0 commit comments