Rot-13: Difference between revisions

Add Dart implementation
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Add Dart implementation)
Line 1,711:
"Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt!".rot13().writeln();
}</syntaxhighlight>
 
=={{header|Dart}}==
{{trans|Swift}}
<syntaxhighlight lang="Dart">
String rot13char(int charCode) {
if ((charCode >= 'A'.codeUnitAt(0) && charCode <= 'M'.codeUnitAt(0)) ||
(charCode >= 'a'.codeUnitAt(0) && charCode <= 'm'.codeUnitAt(0))) {
return String.fromCharCode(charCode + 13);
} else if ((charCode >= 'N'.codeUnitAt(0) && charCode <= 'Z'.codeUnitAt(0)) ||
(charCode >= 'n'.codeUnitAt(0) && charCode <= 'z'.codeUnitAt(0))) {
return String.fromCharCode(charCode - 13);
} else {
return String.fromCharCode(charCode);
}
}
 
String rot13(String str) {
return String.fromCharCodes(str.runes.map((rune) {
return rot13char(rune).codeUnitAt(0);
}));
}
 
void main() {
print(rot13("The quick brown fox jumps over the lazy dog"));
}
</syntaxhighlight>
{{out}}
<pre>
Gur dhvpx oebja sbk whzcf bire gur ynml qbt
 
</pre>
 
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
338

edits