View source code
							
							
						
								Display the source code in std/base64.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						std.base64.Base64Impl.encode  - multiple declarations
				Function Base64Impl.encode
Encode source into a char[] buffer using Base64
 encoding.
						
				char[] encode(R1, R2)
				(
				
				  scope const R1 source,
				
				  scope return R2 buffer
				
				) pure @trusted
				
				if (isArray!R1 && is(ElementType!R1 : ubyte) && is(R2 == char[]));
				
				
				char[] encode(R1, R2)
				(
				
				  R1 source,
				
				  R2 buffer
				
				)
				
				if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : ubyte) && hasLength!R1 && is(R2 == char[]));
						
					
				Parameters
| Name | Description | 
|---|---|
| source | The input range to encode. | 
| buffer | The char[]buffer to store the encoded result. | 
Returns
The slice of buffer that contains the encoded string.
Example
ubyte[6] data = [0x83, 0xd7, 0x30, 0x7a, 0x01, 0x3f];
char[32] buffer;    // much bigger than necessary
// Just to be sure...
auto encodedLength = Base64Function Base64Impl.encode
Encodes source into an output range using Base64 encoding.
						
				size_t encode(E, R)
				(
				
				  scope const(E)[] source,
				
				  auto ref R range
				
				)
				
				if (is(E : ubyte) && isOutputRange!(R, char) && !is(R == char[]));
				
				
				size_t encode(R1, R2)
				(
				
				  R1 source,
				
				  auto ref R2 range
				
				)
				
				if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : ubyte) && hasLength!R1 && !is(R2 == char[]) && isOutputRange!(R2, char));
						
					
				Parameters
| Name | Description | 
|---|---|
| source | The input range to encode. | 
| range | The output range to store the encoded result. | 
Returns
The number of times the output range's put method was invoked.
Example
import stdFunction Base64Impl.encode
Encodes source to newly-allocated buffer.
						
				char[] encode(Range)
				(
				
				  Range source
				
				) pure @safe
				
				if (isArray!Range && is(ElementType!Range : ubyte));
				
				
				char[] encode(Range)
				(
				
				  Range source
				
				)
				
				if (!isArray!Range && isInputRange!Range && is(ElementType!Range : ubyte) && hasLength!Range);
						
					
				This convenience method alleviates the need to manually manage output buffers.
Parameters
| Name | Description | 
|---|---|
| source | The input range to encode. | 
Returns
A newly-allocated char[] buffer containing the encoded string.
Example
ubyte[] data = [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e];
writeln(Base64Authors
Masahiro Nakagawa, Daniel Murphy (Single value Encoder and Decoder)
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.