View source code
							
							
						
								Display the source code in std/utf.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.utf.encode  - multiple declarations
				Function encode
Encodes c into the static array, buf, and returns the actual
    length of the encoded character (a number between 1 and 4 for
    char[4] buffers and a number between 1 and 2 for
    wchar[2] buffers).
						
				size_t encode(Flag!("useReplacementDchar") useReplacementDchar = No
				  out char[4] buf,
				
				  dchar c
				
				) pure @safe;
				
				
				size_t encode(Flag!("useReplacementDchar") useReplacementDchar = No
				  out wchar[2] buf,
				
				  dchar c
				
				) pure @safe;
				
				
				size_t encode(Flag!("useReplacementDchar") useReplacementDchar = No
				  out dchar[1] buf,
				
				  dchar c
				
				) pure @safe;
						
					
				Throws
UTFException if c is not a valid UTF code point.
Example
import stdExample
import stdExample
import stdFunction encode
Encodes c in str's encoding and appends it to str.
						
				void encode(Flag!("useReplacementDchar") useReplacementDchar = No
				  ref char[] str,
				
				  dchar c
				
				) pure @safe;
				
				
				void encode(Flag!("useReplacementDchar") useReplacementDchar = No
				  ref wchar[] str,
				
				  dchar c
				
				) pure @safe;
				
				
				void encode(Flag!("useReplacementDchar") useReplacementDchar = No
				  ref dchar[] str,
				
				  dchar c
				
				) pure @safe;
						
					
				Throws
UTFException if c is not a valid UTF code point.
Example
char[] s = "abcd"Authors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.