Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/String-length/D/string-length-2.d
Normal file
31
Task/String-length/D/string-length-2.d
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import std.stdio, std.range, std.conv;
|
||||
|
||||
void showCodePointsLen(T)(T[] str) {
|
||||
writefln("Character length: %2d - %(%x %)",
|
||||
str.walkLength(), cast(uint[])to!(dchar[])(str));
|
||||
}
|
||||
|
||||
void main() {
|
||||
string s1a = "møøse"; // UTF-8
|
||||
showCodePointsLen(s1a);
|
||||
wstring s1b = "møøse"; // UTF-16
|
||||
showCodePointsLen(s1b);
|
||||
dstring s1c = "møøse"; // UTF-32
|
||||
showCodePointsLen(s1c);
|
||||
writeln();
|
||||
|
||||
string s2a = "𝔘𝔫𝔦𝔠𝔬𝔡𝔢";
|
||||
showCodePointsLen(s2a);
|
||||
wstring s2b = "𝔘𝔫𝔦𝔠𝔬𝔡𝔢";
|
||||
showCodePointsLen(s2b);
|
||||
dstring s2c = "𝔘𝔫𝔦𝔠𝔬𝔡𝔢";
|
||||
showCodePointsLen(s2c);
|
||||
writeln();
|
||||
|
||||
string s3a = "J̲o̲s̲é̲";
|
||||
showCodePointsLen(s3a);
|
||||
wstring s3b = "J̲o̲s̲é̲";
|
||||
showCodePointsLen(s3b);
|
||||
dstring s3c = "J̲o̲s̲é̲";
|
||||
showCodePointsLen(s3c);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue