2013-04-10 23:57:08 -07:00
|
|
|
void main() {
|
2014-04-02 16:56:35 +00:00
|
|
|
import std.range, std.conv;
|
2013-10-27 22:24:23 +00:00
|
|
|
|
2014-04-02 16:56:35 +00:00
|
|
|
string s1 = "hello"; // UTF-8
|
|
|
|
|
assert(s1.retro.text == "olleh");
|
2013-04-10 23:57:08 -07:00
|
|
|
|
2014-04-02 16:56:35 +00:00
|
|
|
wstring s2 = "hello"w; // UTF-16
|
|
|
|
|
assert(s2.retro.wtext == "olleh"w);
|
2013-04-10 23:57:08 -07:00
|
|
|
|
2014-04-02 16:56:35 +00:00
|
|
|
dstring s3 = "hello"d; // UTF-32
|
|
|
|
|
assert(s3.retro.dtext == "olleh"d);
|
|
|
|
|
|
|
|
|
|
// without using std.range:
|
|
|
|
|
dstring s4 = "hello"d;
|
|
|
|
|
assert(s4.dup.reverse == "olleh"d); // simple but inefficient (copies first, then reverses)
|
2013-04-10 23:57:08 -07:00
|
|
|
}
|