Logo

Programming-Idioms

History of Idiom 41 > diff from v11 to v12

Edit summary for version 12 by :

Version 11

2015-08-20, 17:17:30

Version 12

2015-08-20, 18:55:43

Idiom #41 Reverse a string

Create string t containing the same characters as string s, in reverse order.
Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.

Idiom #41 Reverse a string

Create string t containing the same characters as string s, in reverse order.
Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.

Imports
import std.range;
import std.array;
Imports
import std.range, std.array;
Code
auto t = "The key to learning D is to 脚踏实地".retro.array;
Code
auto t = "The key to learning D is to 脚踏实地".retro.array;
Comments bubble
Note, t is now a dchar[], which is a utf-32 encoded string. To convert back to the type of s, you need to call std.conv.to.
Comments bubble
Note, t is now a dchar[], which is a utf-32 encoded string. To convert back to the type of s, you need to call std.conv.to.
Demo URL
http://dpaste.dzfl.pl/b21510935840
Demo URL
http://dpaste.dzfl.pl/b21510935840