Rot-13: Difference between revisions

From Rosetta Code
(→‎{{header|Raku}}: use rotate method)
Line 5,655: Line 5,655:
 
return chr + 13
 
return chr + 13
 
}
 
}
else if (chr >= u8(110) && chr <= u8(122)) || (chr >= u8(78) && chr <= u8(90)) {
+
if (chr >= u8(110) && chr <= u8(122)) || (chr >= u8(78) && chr <= u8(90)) {
 
return chr - 13
 
return chr - 13
 
}
 
}

Revision as of 07:11, 21 September 2022

Task
Rot-13
You are encouraged to solve this task according to the task description, using any language you may know.


Task

Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment).

Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of input contained in each file listed on its command line,   or (if no filenames are passed thereon) acting as a filter on its   "standard input."


(A number of UNIX scripting languages and utilities, such as   awk   and   sed   either default to processing files in this way or have command line switches or modules to easily implement these wrapper semantics, e.g.,   Perl   and   Python).

The   rot-13   encoding is commonly known from the early days of Usenet "Netnews" as a way of obfuscating text to prevent casual reading of   spoiler   or potentially offensive material.

Many news reader and mail user agent programs have built-in rot-13 encoder/decoders or have the ability to feed a message through any external utility script for performing this (or other) actions.

The definition of the rot-13 function is to simply replace every letter of the ASCII alphabet with the letter which is "rotated" 13 characters "around" the 26 letter alphabet from its normal cardinal position   (wrapping around from   z   to   a   as necessary).

Thus the letters   abc   become   nop   and so on.

Technically rot-13 is a   "mono-alphabetic substitution cipher"   with a trivial   "key".

A proper implementation should work on upper and lower case letters, preserve case, and pass all non-alphabetic characters in the input stream through without alteration.


Related tasks


Other tasks related to string operations:
Metrics
Counting
Remove/replace
Anagrams/Derangements/shuffling
Find/Search/Determine
Formatting
Song lyrics/poems/Mad Libs/phrases
Tokenize
Sequences



11l

F rot13(string)
   V r = ‘ ’ * string.len
   L(c) string
      r[L.index] = S c
                      ‘a’..‘z’
                         Char(code' (c.code - ‘a’.code + 13) % 26 + ‘a’.code)
                      ‘A’..‘Z’
                         Char(code' (c.code - ‘A’.code + 13) % 26 + ‘A’.code)
                      E
                         c
   R r

print(rot13(‘foo’))
print(rot13(‘sbb’))
Output:
sbb
foo

360 Assembly

Sytem/360 uses EBCDIC encoding. The power of the CISC architecture, only one hardware instruction (TR) does all the job!

ROT13    CSECT
         USING  ROT13,R15          use calling register
         XPRNT  CC,L'CC
         TR     CC,TABLE           translate
         XPRNT  CC,L'CC
         TR     CC,TABLE           translate
         XPRNT  CC,L'CC
         BR     R14                return to caller
CC       DC     CL10'{NOWHERE!}'
TABLE    DC     CL64' '   
*                    0123456789ABCDEF
         DC     CL16'           .<(+|'   X'4.'
         DC     CL16'          !$*);^'   X'5.'
         DC    CL16'&&          ,%_>?'   X'6.'
         DC     CL16'-/       `:#@''="'   X'7.'
         DC     CL16' nopqrstuv      '   X'8.'
         DC     CL16' wxyzabcde      '   X'9.'
         DC     CL16' ~fghijklm   [  '   X'A.'
         DC     CL16'             ]  '   X'B.'
         DC     CL16'{NOPQRSTUV      '   X'C.'
         DC     CL16'}WXYZABCDE      '   X'D.'
         DC     CL16'\ FGHIJKLM      '   X'E.'
         DC     CL16'0123456789      '   X'F.'
*                    0123456789ABCDEF
         YREGS
         END    ROT13
Output:
{NOWHERE!}
{ABJURER!}
{NOWHERE!}

6502 Assembly

Written for the BeebAsm assembler, which uses '&' to indicate a hexadecimal number. Call with the address of a zero terminated string in X and Y. On exit X is hi-order address of the last page of the string, Y is the length of the string modulo 256 and A is zero unless the string is not terminated.

buffer = $fa               ; or anywhere in zero page that's good
maxpage = $95              ; if non-terminated that's bad

org $1900
.rot13
          stx buffer
          sty buffer+1
          ldy #0
          beq readit
.loop     cmp #$7b          ; high range
          bcs next          ; >= {
          cmp #$41          ; low range
          bcc next          ; < A
          cmp #$4e
          bcc add13         ; < N
          cmp #$5b
          bcc sub13set      ; < [
          cmp #$61
          bcc next          ; < a
          cmp #$6e
          bcs sub13         ; >= n
.add13    adc #13           ; we only get here via bcc; so clc not needed
          bne storeit
.sub13set sec               ; because we got here via bcc; so sec is needed
.sub13    sbc #13           ; we can get here via bcs; so sec not needed
.storeit  sta (buffer),y
.next     iny
          bne readit
          ldx buffer+1
          cpx maxpage
          beq done
          inx
          stx buffer+1
.readit   lda (buffer),y    ; quit on ascii 0
          bne loop
.done     rts
.end
save "rot-13", rot13, end

ACL2

(include-book "arithmetic-3/top" :dir :system)

(defun char-btn (c low high)
   (and (char>= c low)
        (char<= c high)))

(defun rot-13-cs (cs)
   (cond ((endp cs) nil)
         ((or (char-btn (first cs) #\a #\m)
              (char-btn (first cs) #\A #\M))
          (cons (code-char (+ (char-code (first cs)) 13))
                (rot-13-cs (rest cs))))
         ((or (char-btn (first cs) #\n #\z)
              (char-btn (first cs) #\N #\Z))
          (cons (code-char (- (char-code (first cs)) 13))
                (rot-13-cs (rest cs))))
         (t (cons (first cs) (rot-13-cs (rest cs))))))

(defun rot-13 (s)
   (coerce (rot-13-cs (coerce s 'list)) 'string))

Ada

with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Command_Line; use Ada.Command_Line;

procedure Rot_13 is
   
   From_Sequence : Character_Sequence := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   Result_Sequence : Character_Sequence := "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM";
   Rot_13_Mapping : Character_Mapping := To_Mapping(From_Sequence, Result_Sequence);

   In_Char : Character;
   Stdio : Stream_Access := Stream(Ada.Text_IO.Standard_Input);
   Stdout : Stream_Access := Stream(Ada.Text_Io.Standard_Output);
   Input : Ada.Text_Io.File_Type;
 
begin
   if Argument_Count > 0 then
      for I in 1..Argument_Count loop
         begin
            Ada.Text_Io.Open(File => Input, Mode => Ada.Text_Io.In_File, Name => Argument(I));
            Stdio := Stream(Input);
             while not Ada.Text_Io.End_Of_File(Input) loop
               In_Char :=Character'Input(Stdio); 
               Character'Output(Stdout, Value(Rot_13_Mapping, In_Char));
            end loop;
            Ada.Text_IO.Close(Input);
         exception
            when Ada.Text_IO.Name_Error =>
               Ada.Text_Io.Put_Line(File => Ada.Text_Io.Standard_Error, Item => "File " & Argument(I) & " is not a file.");
            when Ada.Text_Io.Status_Error =>
               Ada.Text_Io.Put_Line(File => Ada.Text_Io.Standard_Error, Item => "File " & Argument(I) & " is already opened.");
         end;
      end loop;
   else
      while not Ada.Text_Io.End_Of_File loop
         In_Char :=Character'Input(Stdio); 
         Character'Output(Stdout, Value(Rot_13_Mapping, In_Char));
      end loop;
   end if;
end Rot_13;

ALGOL 68

Translation of: Modula-3
Works with: ALGOL 68 version Standard - no extensions to language used
Works with: ALGOL 68G version Any - tested with release mk15-0.8b.fc9.i386
BEGIN
  CHAR c;
  on logical file end(stand in, (REF FILE f)BOOL: (stop; SKIP));
  on line end(stand in, (REF FILE f)BOOL: (print(new line); FALSE));
  DO
    read(c);
    IF c >= "A" AND c <= "M" OR c >= "a" AND c <= "m" THEN
      c := REPR(ABS c + 13)
    ELIF c >= "N" AND c <= "Z" OR c >= "n" AND c <= "z" THEN
      c := REPR(ABS c - 13)
    FI;
    print(c)
  OD
END # rot13 #

Sample run on linux:

$ echo Big fjords vex quick waltz nymph! | a68g Rot-13.a68
Ovt swbeqf irk dhvpx jnygm alzcu!

APL

Works with: Dyalog APL
r1  ⎕UCS  {+/,13×(65)(<78),(-(78)(90)),(97)(<110),(-(110)(122))}  ⎕UCS
rot13  { r1 ¨  }

⎕UCS is technically implementation-defined, but the bigger problem with portability of the above is that it uses ∘ for function composition. Here's a version that works in a wider variety of implementations:

Works with: GNU APL
r1  { ⎕UCS {+/,13×(65)(<78),(-(78)(90)),(97)(<110),(-(110)(122))} ⎕UCS  }
rot13  { r1 ¨  }
Output:
      rot13 'nowhere ABJURER'
abjurer NOWHERE

AppleScript

Using do shell script

to rot13(textString)
    do shell script "tr a-zA-Z n-za-mN-ZA-M <<<" & quoted form of textString
end rot13

Pure AppleScript solution

to rot13(textString)
    set theIDs to id of textString
    repeat with thisID in theIDs
        if (((thisID < 123) and (thisID > 96)) or ((thisID < 91) and (thisID > 64))) then ¬
            tell (thisID mod 32) to set thisID's contents to thisID - it + (it + 12) mod 26 + 1
    end repeat

    return string id theIDs
end rot13

Demo code:

rot13("nowhere ABJURER")
Output:
abjurer NOWHERE


Or using some generic primitives, and a slightly more functional style of composition:

-- ROT 13 --------------------------------------------------------------------

-- rot13 :: String -> String
on rot13(str)
    script rt13
        on |λ|(x)
            if (x  "a" and x  "m") or (x  "A" and x  "M") then
                character id ((id of x) + 13)
            else if (x  "n" and x  "z") or (x  "N" and x  "Z") then
                character id ((id of x) - 13)
            else
                x
            end if
        end |λ|
    end script
    
    intercalate("", map(rt13, characters of str))
end rot13


-- TEST ----------------------------------------------------------------------
on run
    rot13("nowhere ABJURER")
    
    -->  "abjurer NOWHERE"
end run


-- GENERIC FUNCTIONS ---------------------------------------------------------

-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
    tell mReturn(f)
        set lng to length of xs
        set lst to {}
        repeat with i from 1 to lng
            set end of lst to |λ|(item i of xs, i, xs)
        end repeat
        return lst
    end tell
end map

-- intercalate :: Text -> [Text] -> Text
on intercalate(strText, lstText)
    set {dlm, my text item delimiters} to {my text item delimiters, strText}
    set strJoined to lstText as text
    set my text item delimiters to dlm
    return strJoined
end intercalate

-- Lift 2nd class handler function into 1st class script wrapper 
-- mReturn :: Handler -> Script
on mReturn(f)
    if class of f is script then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn

Applesoft BASIC

100HOME:INPUT"ENTER A STRING:";S$:FORL=1TOLEN(S$):I$=MID$(S$,L,1):LC=(ASC(I$)>95)*32:C$=CHR$(ASC(I$)-LC):IFC$>="A"ANDC$<="Z"THENC$=CHR$(ASC(C$)+13):C$=CHR$(ASC(C$)-26*(C$>"Z")):I$=CHR$(ASC(C$)+LC)
110A$=A$+I$:NEXT:PRINTA$

Arturo

rot13: function [c][
    case [in? lower c]
        when? -> `a`..`m` -> return to :char (to :integer c) + 13
        when? -> `n`..`z` -> return to :char (to :integer c) - 13
        else  -> return c
]

loop "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 'ch 
    -> prints rot13 ch

print ""
Output:
NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm

AutoHotkey

Simple alphabet remapping method by Raccoon. Similar to a translate() function in many languages.

ROT13(string) ; by Raccoon July-2009
{
  Static a := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
  Static b := "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM "
  s=
  Loop, Parse, string
  {
    c := substr(b,instr(a,A_LoopField,True),1)
    if (c != " ")
      s .= c
    else
      s .= A_LoopField
  }
  Return s
}

Simple ASCII math method by Raccoon. Add or subtract 13 depending on the character's decimal value.

ROT13(string) ; by Raccoon July-2009
{
  s=
  Loop, Parse, string
  {
    c := asc(A_LoopField)
    if (c >= 97) && (c <= 109) || (c >= 65) && (c <= 77)
      c += 13
    else if (c >= 110) && (c <= 122) || (c >= 78) && (c <= 90)
      c -= 13
    s .= chr(c)
  }
  Return s
}

Code modified from stringmod by Hugo: ahk discussion

Str0=Hello, This is a sample text with 1 2 3 or other digits!@#$^&*()-_=
Str1 := Rot13(Str0)
Str2 := Rot13(Str1)
MsgBox % Str0 "`n" Str1 "`n" Str2

Rot13(string) 
{
   Loop Parse, string
   {
      char := Asc(A_LoopField)
      ; o is 'A' code if it is an uppercase letter, and 'a' code if it is a lowercase letter
      o := Asc("A") * (Asc("A") <= char && char <= Asc("Z")) + Asc("a") * (Asc("a") <= char && char <= Asc("z"))
      If (o > 0)
      {
         ; Set between 0 and 25, add rotation factor, modulus alphabet size
         char := Mod(char - o + 13, 26)
         ; Transform back to char, upper or lower
         char := Chr(char + o)
      }
      Else
      {
         ; Non alphabetic, unchanged
         char := A_LoopField
      }
      rStr .= char
   }
   Return rStr
}

from LinearSpoon's Translation of The Worlds Shortest C Implementation of Rot13

Rot13(string) {
  Output := ""
  Loop, Parse, string
  {
    a := ~Asc(A_LoopField)
    Output .= Chr(~a-1//(~(a|32)//13*2-11)*13)
  }
  return Output
}

AWK

Works with: gawk
# usage: awk -f rot13.awk 
BEGIN {
  for(i=0; i < 256; i++) {
    amap[sprintf("%c", i)] = i
  }
  for(l=amap["a"]; l <= amap["z"]; l++) {
    rot13[l] = sprintf("%c", (((l-amap["a"])+13) % 26 ) + amap["a"])
  }
  FS = ""
}
{
  o = ""
  for(i=1; i <= NF; i++) {
    if ( amap[tolower($i)] in rot13 ) {
      c = rot13[amap[tolower($i)]]
      if ( tolower($i) != $i ) c = toupper(c)
      o = o c
    } else {
      o = o $i
    }
  }
  print o
}
Input:
Hello, HAL !
Output:
Uryyb, UNY !

BaCon

INPUT "String: ", s$
PRINT "Output: ", REPLACE$(s$, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM", 2)
Output:
user@host $ ./rot13 
String: Oolite quick Thargoid jumps lazy Vipers = blown up + special fx
Output: Bbyvgr dhvpx Gunetbvq whzcf ynml Ivcref = oybja hc + fcrpvny sk

BASIC

Works with: QBasic
CLS
INPUT "Enter a string: ", s$
ans$ = ""
FOR a = 1 TO LEN(s$)
        letter$ = MID$(s$, a, 1)
        IF letter$ >= "A" AND letter$ <= "Z" THEN
                char$ = CHR$(ASC(letter$) + 13)
                IF char$ > "Z" THEN char$ = CHR$(ASC(char$) - 26)
        ELSEIF letter$ >= "a" AND letter$ <= "z" THEN
                char$ = CHR$(ASC(letter$) + 13)
                IF char$ > "z" THEN char$ = CHR$(ASC(char$) - 26)
        ELSE
                char$ = letter$
        END IF
        ans$ = ans$ + char$
NEXT a
PRINT ans$

Alternate version

This version does the rotation in-place without the use of a second variable.

INPUT "Enter a string "; Text$
FOR c% = 1 TO LEN(Text$)
    SELECT CASE ASC(MID$(Text$, c%, 1))
        CASE 65 TO 90
            MID$(Text$, c%, 1) = CHR$(65 + ((ASC(MID$(Text$, c%, 1)) - 65 + 13) MOD 26))
        CASE 97 TO 122
            MID$(Text$, c%, 1) = CHR$(97 + ((ASC(MID$(Text$, c%, 1)) - 97 + 13) MOD 26))
    END SELECT
NEXT c%
PRINT "Converted......: "; Text$
Output:
Enter a string ? Oolite quick Thargoid jumps lazy Vipers = blown up + special fx
Converted......: Bbyvgr dhvpx Gunetbvq whzcf ynml Ivcref = oybja hc + fcrpvny sk
See also
BBC BASIC, FBSL, GW-BASIC, Liberty BASIC, Locomotive Basic, PureBasic, Run BASIC, TI-83 BASIC, Visual Basic .NET, ZX Spectrum Basic

BASIC256

# rot13 Cipher v2.0
# basic256 1.1.4.0
# 2101031238
 
dec$ = ""
type$ = "cleartext "
ctext$ = ""
sp = 0
iOffset = 13             #offset assumed to be 13 - uncomment line 11 to change
 
input "For decrypt enter " + "<d> " + " -- else press enter > ",dec$  
# input "Enter offset > ", iOffset

if dec$ = "d" OR dec$ = "D" then
    iOffset = 26 - iOffset
    type$ = "ciphertext "
end if
 
input "Enter " + type$ + "> ", str$
str$ = upper(str$)          
 
for i = 1 to length(str$)
    iTemp =  asc(mid(str$,i,1))
    if iTemp > 64 AND iTemp < 91 then
           iTemp = ((iTemp - 65) + iOffset) % 26
           print chr(iTemp + 65);
           sp = sp + 1
           if sp = 5 then
              print(' ');
              sp = 0
           endif
    endif
next i
Output:
This is a rewrite of the original version. 

Output:
We are discovered. Flee at once.

JRNER QVFPB IRERQ SYRRN GBAPR 

Batch File

@echo off & setlocal enabledelayedexpansion

:: ROT13 obfuscator Michael Sanders - 2017
::
:: example: rot13.cmd Rire abgvpr cflpuvpf arire jva gur ybggrel?

:setup

   set str=%*
   set buf=%str%
   set len=0

:getlength

   if not defined buf goto :start
   set buf=%buf:~1%
   set /a len+=1
   goto :getlength

:start

   if %len% leq 0 (echo rot13: zero length string & exit /b 1)
   set abc=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
   set nop=NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm
   set r13=
   set num=0
   set /a len-=1

:rot13

   for /l %%x in (!num!,1,%len%) do (
      set log=0
      for /l %%y in (0,1,51) do (
         if "!str:~%%x,1!"=="!abc:~%%y,1!" (
            call set r13=!r13!!nop:~%%y,1!
            set /a num=%%x+1
            set /a log+=1
            if !num! lss %len% goto :rot13
         )
      )
      if !log!==0 call set r13=!r13!!str:~%%x,1!
   )

:done

   echo !r13!
   endlocal & exit /b 0

BBC BASIC

      REPEAT
        INPUT A$
        PRINT FNrot13(A$)
      UNTIL FALSE
      END
      
      DEF FNrot13(A$)
      LOCAL A%,B$,C$
      IF A$="" THEN =""
      FOR A%=1 TO LEN A$
        C$=MID$(A$,A%,1)
        IF C$<"A" OR (C$>"Z" AND C$<"a") OR C$>"z" THEN
          B$=B$+C$
        ELSE
          IF (ASC(C$) AND &DF)<ASC("N") THEN
            B$=B$+CHR$(ASC(C$)+13)
          ELSE
            B$=B$+CHR$(ASC(C$)-13)
          ENDIF
        ENDIF
      NEXT A%
      =B$

BCPL

get "libhdr"

let rot13(x) =
    'A' <= x <= 'Z' -> (x - 'A' + 13) rem 26 + 'A',
    'a' <= x <= 'z' -> (x - 'a' + 13) rem 26 + 'a',
    x
    
let start() be
$(  let ch = rdch()
    if ch = endstreamch then break
    wrch(rot13(ch))
$) repeat

Befunge

~:"z"`#v_:"m"`#v_:"`"` |>
 :"Z"`#v_:"M"`#v_:"@"`|>
 : 0 `#v_@v-6-7<      >
,      <  <+6+7       <<v

Burlesque

blsq ) "HELLO WORLD"{{'A'Zr\\/Fi}m[13?+26.%'A'Zr\\/si}ww
"URYYB JBEYQ"
blsq ) "URYYB JBEYQ"{{'A'Zr\\/Fi}m[13?+26.%'A'Zr\\/si}ww
"HELLO WORLD"

C

The following code can handle all character sets, even if the letters are not in a contiguous range (in ASCII they are, in EBCDIC they aren't).

#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

static char rot13_table[UCHAR_MAX + 1];

static void init_rot13_table(void) {
	static const unsigned char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	static const unsigned char lower[] = "abcdefghijklmnopqrstuvwxyz";

	for (int ch = '\0'; ch <= UCHAR_MAX; ch++) {
		rot13_table[ch] = ch;
	}
	for (const unsigned char *p = upper; p[13] != '\0'; p++) {
		rot13_table[p[0]] = p[13];
		rot13_table[p[13]] = p[0];
	}
	for (const unsigned char *p = lower; p[13] != '\0'; p++) {
		rot13_table[p[0]] = p[13];
		rot13_table[p[13]] = p[0];
	}
}

static void rot13_file(FILE *fp)
{
	int ch;
	while ((ch = fgetc(fp)) != EOF) {
		fputc(rot13_table[ch], stdout);                
	}
}

int main(int argc, char *argv[])
{
	init_rot13_table();

	if (argc > 1) {
		for (int i = 1; i < argc; i++) {
			FILE *fp = fopen(argv[i], "r");
			if (fp == NULL) {
				perror(argv[i]);
				return EXIT_FAILURE;
			}
			rot13_file(fp);
			fclose(fp);
		}
	} else {
		rot13_file(stdin);
	}
	return EXIT_SUCCESS;
}

C#

using System;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static char Rot13(char c)
    {
        if ('a' <= c && c <= 'm' || 'A' <= c && c <= 'M')
        {
            return (char)(c + 13);
        }
        if ('n' <= c && c <= 'z' || 'N' <= c && c <= 'Z')
        {
            return (char)(c - 13);
        }
        return c;
    }

    static string Rot13(string s)
    {
        return new string(s.Select(Rot13).ToArray());
    }


    static void Main(string[] args)
    {
        foreach (var file in args.Where(file => File.Exists(file)))
        {
            Console.WriteLine(Rot13(File.ReadAllText(file)));
        }
        if (!args.Any())
        {
            Console.WriteLine(Rot13(Console.In.ReadToEnd()));
        }
    }
}

C++

#include <iostream>
#include <istream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>

// the rot13 function
std::string rot13(std::string s)
{
  static std::string const
    lcalph = "abcdefghijklmnopqrstuvwxyz",
    ucalph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  std::string result;
  std::string::size_type pos;

  result.reserve(s.length());

  for (std::string::iterator it = s.begin(); it != s.end(); ++it)
  {
    if ( (pos = lcalph.find(*it)) != std::string::npos )
      result.push_back(lcalph[(pos+13) % 26]);
    else if ( (pos = ucalph.find(*it)) != std::string::npos )
      result.push_back(ucalph[(pos+13) % 26]);
    else
      result.push_back(*it);
  }

  return result;
}

// function to output the rot13 of a file on std::cout
// returns false if an error occurred processing the file, true otherwise
// on entry, the argument is must be open for reading
int rot13_stream(std::istream& is)
{
  std::string line;
  while (std::getline(is, line))
  {
    if (!(std::cout << rot13(line) << "\n"))
      return false;
  }
  return is.eof();
}

// the main program
int main(int argc, char* argv[])
{
  if (argc == 1) // no arguments given
    return rot13_stream(std::cin)? EXIT_SUCCESS : EXIT_FAILURE;

  std::ifstream file;
  for (int i = 1; i < argc; ++i)
  {
    file.open(argv[i], std::ios::in);
    if (!file)
    {
      std::cerr << argv[0] << ": could not open for reading: " << argv[i] << "\n";
      return EXIT_FAILURE;
    }
    if (!rot13_stream(file))
    {
      if (file.eof())
        // no error occurred for file, so the error must have been in output
        std::cerr << argv[0] << ": error writing to stdout\n";
      else
        std::cerr << argv[0] << ": error reading from " << argv[i] << "\n";
      return EXIT_FAILURE;
    }
    file.clear();
    file.close();
    if (!file)
      std::cerr << argv[0] << ": warning: closing failed for " << argv[i] << "\n";
  }
  return EXIT_SUCCESS;
}

Here is an other approach which can rotate by any number:

Library: Boost
#include <iostream>
#include <string>
#include <boost/iostreams/concepts.hpp>    // output_filter
#include <boost/iostreams/operations.hpp>  // put
#include <boost/iostreams/filtering_stream.hpp>
#include <fstream>
namespace io = boost::iostreams;

class rot_output_filter : public io::output_filter 
{
public:
    explicit rot_output_filter(int r=13):rotby(r),negrot(alphlen-r){};

    template<typename Sink>
    bool put(Sink& dest, int c){
        char uc = toupper(c);

        if(('A' <= uc) && (uc <= ('Z'-rotby)))
            c = c + rotby;
        else if ((('Z'-rotby) <= uc) && (uc <= 'Z'))
            c = c - negrot;
        return boost::iostreams::put(dest, c);
    };
private:
        static const int alphlen = 26;
        const int rotby;
        const int negrot;
};

int main(int argc, char *argv[])
{
    io::filtering_ostream out;
    out.push(rot_output_filter(13));
    out.push(std::cout);

    if (argc == 1) out << std::cin.rdbuf();
    else for(int i = 1; i < argc; ++i){
        std::ifstream in(argv[i]);
        out << in.rdbuf();
    }
}

C++11

#include <string>
#include <iostream>
#include <fstream>

char rot13(const char c){
	if (c >= 'a' && c <= 'z')
		return (c - 'a' + 13) % 26 + 'a';
	else if (c >= 'A' && c <= 'Z')
		return (c - 'A' + 13) % 26 + 'A';
	return c;
}

std::string &rot13(std::string &s){
	for (auto &c : s) //range based for is the only used C++11 feature
		c = rot13(c);
	return s;
}

void rot13(std::istream &in, std::ostream &out){
	std::string s;
	while (std::getline(in, s))
		out << rot13(s) << '\n';
}

int main(int argc, char *argv[]){
	if (argc == 1)
		rot13(std::cin, std::cout);
	for (int arg = 1; arg < argc; ++arg){
		std::ifstream f(argv[arg]);
		if (!f)
			return EXIT_FAILURE;
		rot13(f, std::cout);
	}
}

Clojure

All invocations produce "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt!"

(ns rosettacode.rot-13)

(let [a (int \a) m (int \m) A (int \A) M (int \M)
      n (int \n) z (int \z) N (int \N) Z (int \Z)]
  (defn rot-13 [^Character c]
    (char (let [i (int c)]
      (cond-> i
        (or (<= a i m) (<= A i M)) (+ 13)
        (or (<= n i z) (<= N i Z)) (- 13))))))

(apply str (map rot-13 "The Quick Brown Fox Jumped Over The Lazy Dog!"))

; An alternative implementation using a map:
(let [A (into #{} "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
      Am (->> (cycle A) (drop 26) (take 52) (zipmap A))]
  (defn rot13 [^String in]
    (apply str (map #(Am % %) in))))

(rot13 "The Quick Brown Fox Jumped Over The Lazy Dog!")

CLU

rot13 = proc (c: char) returns (char)
    base: int
    letter: bool := false
    if c>='A' & c<='Z' then
        base := char$c2i('A')
        letter := true
    elseif c>='a' & c<='z' then
        base := char$c2i('a')
        letter := true
    end
    if ~letter then return(c) end
    return(char$i2c((char$c2i(c)-base+13)//26+base))
end rot13

start_up = proc ()
    po: stream := stream$primary_output()
    pi: stream := stream$primary_input()
    while true do
        stream$putc(po,rot13(stream$getc(pi)))
        except when end_of_file: break end
    end
end start_up

COBOL

       IDENTIFICATION DIVISION.
       PROGRAM-ID. rot-13.

       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       78  STR-LENGTH   VALUE 100.
 
       78  normal-lower VALUE "abcdefghijklmnopqrstuvwxyz".
       78  rot13-lower  VALUE "nopqrstuvwxyzabcdefghijklm".

       78  normal-upper VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
       78  rot13-upper  VALUE "NOPQRSTUVWXYZABCDEFGHIJKLM".

       LINKAGE SECTION.
       01  in-str       PIC X(STR-LENGTH).
       01  out-str      PIC X(STR-LENGTH).

       PROCEDURE DIVISION USING VALUE in-str, REFERENCE out-str.
           MOVE in-str TO out-str

           INSPECT out-str CONVERTING normal-lower TO rot13-lower
           INSPECT out-str CONVERTING normal-upper TO rot13-upper

           GOBACK
           .

Commodore BASIC

Very generic implementation. Please note that in Commodore BASIC, SHIFT-typed letters (to generate either graphic symbols in upper-case mode, or capital letters in lower-case mode) do not translate to PETSCII characters 97 through 122, but instead to characters 193 through 218.

1 rem rot-13 cipher
2 rem rosetta code
10 print chr$(147);chr$(14);
25 gosub 1000
30 print chr$(147);"Enter a message to translate."
35 print:print "Press CTRL-Z when finished.":print
40 mg$="":gosub 2000
45 print chr$(147);"Processing...":gosub 3000
50 print chr$(147);"The translated message is:"
55 print:print cm$
100 print:print "Do another one? ";
110 get k$:if k$<>"y" and k$<>"n" then 110
120 print k$:if k$="y" then goto 10
130 end

1000 rem generate encoding table
1010 ec$="mnopqrstuvwxyzabcdefghijklMNOPQRSTUVWXYZABCDEFGHIJKL"
1099 return

2000 rem get user input routine
2005 print chr$(18);" ";chr$(146);chr$(157);
2010 get k$:if k$="" then 2010
2012 if k$=chr$(13) then print " ";chr$(157);
2015 print k$;
2020 if k$=chr$(20) then mg$=left$(mg$,len(mg$)-1):goto 2040
2025 if len(mg$)=255 or k$=chr$(26) then return
2030 mg$=mg$+k$
2040 goto 2005

3000 rem translate message
3005 cm$=""
3010 for i=1 to len(mg$)
3015 c=asc(mid$(mg$,i,1))
3020 if c<65 or (c>90 and c<193) or c>218 then cm$=cm$+chr$(c):goto 3030
3025 if c>=65 and c<=90 then c=c-64
3030 if c>=193 and c<=218 then c=(c-192)+26
3035 cm$=cm$+mid$(ec$,c,1)
3040 next i
3050 return
Output:
Enter a message to translate.              
                                          
Press CTRL-Z when finished.

You know it is going to be a bad day
when the letters in your alphabet soup
spell D-I-S-A-S-T-E-R.

Processing...

The translated message is:                 
                                        
Lbh xabj vg vf tbvat gb or n onq qnl
jura gur yrggref va lbhe nycunorg fbhc
fcryy Q-V-F-N-F-G-R-E.                 
                                        
Do another one? n

ready.
█


Common Lisp

The standard gives implementations great leeway with respect to character encodings, so we can't rely on the convenient properties of ASCII.

(defconstant +alphabet+
'(#\A #\B #\C #\D #\E #\F #\G #\H #\I #\J #\K #\L #\M #\N #\O #\P
  #\Q #\R #\S #\T #\U #\V #\W #\X #\Y #\Z))

(defun rot13 (s)
  (map 'string
    (lambda (c &aux (n (position (char-upcase c) +alphabet+)))
      (if n
        (funcall
          (if (lower-case-p c) #'char-downcase #'identity)
          (nth (mod (+ 13 n) 26) +alphabet+))
        c))
    s))

Assuming ASCII Character Set

Though the standard intentionally doesn't specify encoding, every popular implementation today uses ASCII.

(defun rot13 (string)
  (map 'string
       (lambda (char &aux (code (char-code char)))
         (if (alpha-char-p char)
             (if (> (- code (char-code (if (upper-case-p char)
                                           #\A #\a))) 12)
                 (code-char (- code 13))
                 (code-char (+ code 13)))
             char))
       string))

(rot13 "Moron") ; -> "Zbeba"

Alternative version

1. Equality

a = "abcdefghijklm" . "zyxwvutsrqpon"

rot(a) = a
     i    length(a) - i - 1

2. Application

(defconstant +a+ "AaBbCcDdEeFfGgHhIiJjKkLlMmzZyYxXwWvVuUtTsSrRqQpPoOnN")

(defun rot (txt)
  (map 'string
    #'(lambda (x)
        (if (find x +a+)
          (char +a+ (- 51 (position x +a+)))
          x))
    txt))

3. Execution

Output:
(rot "Usenet rulez !")
Hfrarg ehyrm !
(rot "Hfrarg ehyrm !")
Usenet rulez !

That's all Folks !


cyril nocton : <cyril.nocton@gmail.com>

Cubescript

alias rot13 [
	push alpha [
		"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
		"a b c d e f g h i j k l m n o p q r s t u v w x y z"
	] [ push chars [] [
		loop i (strlen $arg1) [
			looplist n $alpha [
				if (! (listlen $chars)) [
					alias chars (? (> (listindex $n (substr $arg1 $i 1)) -1) $n [])
				]
			]
			alias arg1 (
				concatword (substr $arg1 0 $i) (
					? (listlen $chars) (
						at $chars (
							mod (+ (
								listindex $chars (substr $arg1 $i 1)
							) 13 ) (listlen $chars)
						)
					) (substr $arg1 $i 1)
				) (substr $arg1 (+ $i 1) (strlen $arg1))
			)
			alias chars []
		]
	] ]
	result $arg1
]

Usage:

>>> rot13 "Hello World"
> Uryyb Jbeyq
>>> rot13 "Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt!"
> The Quick Brown Fox Jumps Over The Lazy Dog!

D

Using Standard Functions

import std.stdio;
import std.ascii: letters, U = uppercase, L = lowercase;
import std.string: makeTrans, translate;

immutable r13 = makeTrans(letters,
                          //U[13 .. $] ~ U[0 .. 13] ~
                          U[13 .. U.length] ~ U[0 .. 13] ~
                          L[13 .. L.length] ~ L[0 .. 13]);

void main() {
    writeln("This is the 1st test!".translate(r13, null));
}
Output:
The Quick Brown Fox Jumps Over The Lazy Dog!

Imperative Implementation

import std.stdio, std.string, std.traits;

pure S rot13(S)(in S s) if (isSomeString!S) {
    return rot(s, 13);
}

pure S rot(S)(in S s, in int key) if (isSomeString!S) {
    auto r = s.dup;

    foreach (i, ref c; r) {
        if ('a' <= c && c <= 'z')
            c = ((c - 'a' + key) % 26 + 'a');
        else if ('A' <= c && c <= 'Z')
            c = ((c - 'A' + key) % 26 + 'A');
    }
    return cast(S) r;
}

void main() {
    "Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt!".rot13().writeln();
}

Delphi

Translation of: Go
program Rot13;

{$APPTYPE CONSOLE}

uses
  System.SysUtils;

function Rot13char(c: AnsiChar): AnsiChar;
begin
  Result := c;
  if c in ['a'..'m', 'A'..'M'] then
    Result := AnsiChar(ord(c) + 13)
  else if c in ['n'..'z', 'N'..'Z'] then
    Result := AnsiChar(ord(c) - 13);
end;

function Rot13Fn(s: ansistring): ansistring;
var i: Integer;
begin
  SetLength(result, length(s));
  for i := 1 to length(s) do
    Result[i] := Rot13char(s[i]);
end;

begin
  writeln(Rot13Fn('nowhere ABJURER'));
  readln;
end.

Dyalect

func Char.Rot13() {
    return Char(this.Order() + 13)
        when this is >= 'a' and <= 'm' or >= 'A' and <= 'M'
    return Char(this.Order() - 13)
        when this is >= 'n' and <= 'z' or >= 'N' and <= 'Z'
    return this
}
 
func String.Rot13() {
    var cs = []
    for c in this {
        cs.Add(c.Rot13())
    }
    String.Concat(values: cs)
}
 
"ABJURER nowhere".Rot13()
Output:
"NOWHERE abjurer"

Déjà Vu

rot-13:
	)
	for ch in chars swap:
		ord ch
		if <= 65 dup:
			if >= 90 dup:
				+ 13 - swap 65
				+ 65 % swap 26
		if <= 97 dup:
			if >= 122 dup:
				+ 13 - swap 97
				+ 97 % swap 26
		chr
	concat(

!print rot-13 "Snape kills Frodo with Rosebud."
Output:
Fancr xvyyf Sebqb jvgu Ebfrohq.

E

pragma.enable("accumulator")

var rot13Map := [].asMap()
for a in ['a', 'A'] {
    for i in 0..!26 {
        rot13Map with= (a + i, E.toString(a + (i + 13) % 26))
    }
}

def rot13(s :String) {
  return accum "" for c in s { _ + rot13Map.fetch(c, fn{ c }) }
}

Elena

ELENA 4.x :

import system'routines;
import extensions;
import extensions'text;
 
singleton rotConvertor
{
    char convert(char ch)
    {
        if (($97 <= ch && ch <= $109) || ($65 <= ch && ch <= $77))
        {
            ^ (ch.toInt() + 13).toChar()
        };
        if (($110 <= ch && ch <= $122) || ($78 <= ch && ch <= $90))
        {
            ^ (ch.toInt() - 13).toChar()
        };
 
        ^ ch
    }
 
    string convert(string s)
        = s.selectBy:(ch => rotConvertor.convert(ch)).summarize(new StringWriter());
}
 
public program()
{
    if (program_arguments.Length > 1)
    {
        console.printLine(rotConvertor.convert(program_arguments[1]))
    }
}
Output:
rot13 "Hello World"
Hryyb Wbeyq

Elixir

A simple conditional version.

Translation of: Erlang
defmodule RC do
  def rot13(clist) do
    f = fn(c) when (?A <= c and c <= ?M) or (?a <= c and c <= ?m) -> c + 13
          (c) when (?N <= c and c <= ?Z) or (?n <= c and c <= ?z) -> c - 13
          (c) -> c
        end
    Enum.map(clist, f)
  end
end
 
IO.inspect encode = RC.rot13('Rosetta Code')
IO.inspect RC.rot13(encode)
Output:
'Ebfrggn Pbqr'
'Rosetta Code'

A functional version.

defmodule Rot13 do
  @moduledoc """
  ROT13 encoding program. Takes user input and outputs encoded text.
  """

  @spec sign(integer | float) :: -1 | 1
  def sign(int) do
    if int >= 0 do 1
    else          -1
    end
  end

  @spec rotate(charlist) :: charlist
  def rotate(string_chars) do
    string_chars
      |> Enum.map(
        fn char ->
          char_up = << char :: utf8 >>
            |> String.upcase()
            |> String.to_charlist()
            |> Enum.at(0)
          if ?A <= char_up and char_up <= ?Z do
            <<
              char + (-13 * trunc(sign(char_up - 77.5))) :: utf8
            >>
          else
            << char :: utf8 >>
          end
        end)
  end

  @spec start(any, any) :: {:ok, pid}
  def start(_type, _args) do
    IO.puts("Enter string to encode:")
    IO.puts(
      [
        "Encoded string:\n",
        IO.read(:line)
          |> String.trim()
          |> String.to_charlist()
          |> rotate()
      ]
    )
    Task.start(fn -> :timer.sleep(1000) end)
  end
end
Output:
Enter string to encode:
NOWHERE abjurer Rosetta Code 123
Encoded string:
ABJURER nowhere Ebfrggn Pbqr 123

Emacs Lisp

Emacs comes with built-in rot-13 support for translating strings, buffers and regions:

(rot13-string "abc") ;=> "nop"
(with-temp-buffer
  (insert "abc")
  (rot13-region (point-min) (point-max))
  (buffer-string)) ;=> "nop"

A more specialized version which only works on strings:

(defun rot-13 (string)
  (let* ((len (length string))
         (output (make-string len ?\s)))
    (dotimes (i len)
      (let ((char (aref string i)))
        (cond
         ((or (and (>= char ?n) (<= char ?z))
              (and (>= char ?N) (<= char ?Z)))
          (aset output i (- char 13)))
         ((or (and (>= char ?a) (<= char ?m))
              (and (>= char ?A) (<= char ?M)))
          (aset output i (+ char 13)))
         (t
          (aset output i char)))))
    output))

Erlang

rot13(Str) ->
    F = fun(C) when (C >= $A andalso C =< $M); (C >= $a andalso C =< $m) -> C + 13;
           (C) when (C >= $N andalso C =< $Z); (C >= $n andalso C =< $z) -> C - 13;
           (C) -> C
        end,
    lists:map(F, Str).

ERRE

PROGRAM ROT13

BEGIN
INPUT("Enter a string ",TEXT$)
FOR C%=1 TO LEN(TEXT$) DO
    A%=ASC(MID$(TEXT$,C%,1))
    CASE A% OF
            65..90->
                   MID$(TEXT$,C%,1)=CHR$(65+(A%-65+13) MOD 26)
            END ->
            97..122->
                   MID$(TEXT$,C%,1)=CHR$(97+(A%-97+13) MOD 26)
            END ->
    END CASE
END FOR
PRINT("Converted: ";TEXT$)
END PROGRAM
Output:
Enter a string ? pippo
Converted: cvccb

Euphoria

Works with: Euphoria version 4.0.0
include std/types.e
include std/text.e

atom FALSE = 0
atom TRUE = not FALSE

function Rot13( object oStuff )
	integer iOffset
	integer bIsUpper
	object oResult
	sequence sAlphabet = "abcdefghijklmnopqrstuvwxyz"
	if sequence(oStuff) then
		oResult = repeat( 0, length( oStuff ) )
		for i = 1 to length( oStuff ) do
			oResult[ i ] = Rot13( oStuff[ i ] )
		end for
	else
		bIsUpper = FALSE
		if t_upper( oStuff ) then
			bIsUpper = TRUE
			oStuff = lower( oStuff )
		end if
		iOffset = find( oStuff, sAlphabet )
		if iOffset != 0 then
			iOffset += 13
			iOffset = remainder( iOffset, 26 )
			if iOffset = 0 then iOffset = 1 end if
			oResult = sAlphabet[iOffset]
			if bIsUpper then
				oResult = upper(oResult)
			end if
		else
			oResult = oStuff --sprintf( "%s", oStuff )
		end if
	end if
	return oResult
end function

puts( 1, Rot13( "abjurer NOWHERE." ) & "\n" )

F#

Illustrates turning a string into an array of chars then composition of type casting with a conversion function. We create a composite that converts its input to an integer, calls the convertion function and then casts to a char type. The result is an array of modified chars that we can use to create a new string.

let rot13 (s : string) =
   let rot c =
       match c with
       | c when c > 64 && c < 91 -> ((c - 65 + 13) % 26) + 65
       | c when c > 96 && c < 123 -> ((c - 97 + 13) % 26) + 97
       | _ -> c
   s |> Array.of_seq
   |> Array.map(int >> rot >> char)
   |> (fun seq -> new string(seq))

Factor

#! /usr/bin/env factor

USING: kernel io ascii math combinators sequences ;
IN: rot13

: rot-base ( ch ch -- ch ) [ - 13 + 26 mod ] keep + ;

: rot13-ch ( ch -- ch )
    {
        { [ dup letter? ] [ CHAR: a rot-base ] }
        { [ dup LETTER? ] [ CHAR: A rot-base ] }
        [ ]
    }
    cond ;

: rot13 ( str -- str ) [ rot13-ch ] map ;

: main ( -- )
    [ readln dup ]
    [ rot13 print flush ]
    while
    drop ;

MAIN: main

FALSE

[^$1+][$32|$$'z>'a@>|$[\%]?~[13\'m>[_]?+]?,]#%

Fantom

class Rot13
{
  static Str rot13 (Str input)
  {
    Str result := ""
    input.each |Int c|
    {
      if ((c.lower >= 'a') && (c.lower <= 'm'))
        result += (c+13).toChar
      else if ((c.lower >= 'n') && (c.lower <= 'z'))
        result += (c-13).toChar
      else
        result += c.toChar
    }
    return result
  }

  public static Void main (Str[] args)
  {
    if (args.size == 1)
    { // process each line of given file
      Str filename := args[0]
      File(filename.toUri).eachLine |Str line|
      {
        echo (rot13(line))
      }
    }
    else
    {
      echo ("Test:")
      Str text := "abcstuABCSTU123!+-"
      echo ("Text $text becomes ${rot13(text)}")
    }
  }
}

FBSL

Implements a circular queue, finds the required character and then rotates the queue forward 13 places. Would do as a solution to Caesar Cipher with a different rotation number. Please note that FBSL is not case sensitive, thus the use of lstrcmp.

#APPTYPE CONSOLE

REM Create a CircularQueue object
REM CQ.Store item
REM CQ.Find items
REM CQ.Forward nItems
REM CQ.Recall

REM SO CQ init WITH "A"... "Z"
REM CQ.Find "B"
REM QC.Forward 13
REM QC.Recall

CLASS CircularQueue
	items[]
	head
	tail
	here
	
	SUB INITIALIZE(dArray)
		head = 0
		tail = 0
		here = 0
		FOR DIM i = LBOUND(dArray) TO UBOUND(dArray)
			items[tail] = dArray[i]
			tail = tail + 1
		NEXT
	END SUB
	
	SUB TERMINATE()
		REM
	END SUB
	
	METHOD Put(s AS STRING)
		items[tail] = s
		tail = tail + 1
	END METHOD
	
	METHOD Find(s AS STRING)
		FOR DIM i = head TO tail - 1
			IF items[i] = s THEN
				here = i
				RETURN TRUE
			END IF
		NEXT
		RETURN FALSE
	END METHOD
	
	METHOD Move(n AS INTEGER)
		DIM bound AS INTEGER = UBOUND(items) + 1
		here = (here + n) MOD bound
	END METHOD
	
	METHOD Recall()
		RETURN items[here]
	END METHOD
	
	PROPERTY Size()
		RETURN COUNT(items)
	END PROPERTY
END CLASS

DIM CQ AS NEW CircularQueue({"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"})

DIM c AS STRING
DIM isUppercase AS INTEGER
DIM s AS STRING = "nowhere ABJURER"

FOR DIM i = 1 TO LEN(s)
	c = MID(s, i, 1)
	isUppercase = lstrcmp(LCASE(c), c)
	IF CQ.Find(UCASE(c)) THEN
		CQ.Move(13)
		PRINT IIF(isUppercase, UCASE(CQ.Recall()), LCASE(CQ.Recall())) ;
	ELSE
		PRINT c;
	END IF
NEXT

PAUSE

Forth

A simple version, using nested conditionals.

: r13 ( c -- o )
  dup 32 or                                    \ tolower
  dup [char] a [char] z 1+ within if
    [char] m > if -13 else 13 then +
  else drop then ;

A table driven version which should be more efficient. The mechanism is flexible enough to express any sort of transform.

: ,chars ( end start -- )
  do i c, loop ;

: xlate create does> ( c -- c' ) + c@ ;

xlate rot13 
  char A         0    ,chars
  char Z 1+ char N    ,chars
  char N    char A    ,chars
  char a    char Z 1+ ,chars
  char z 1+ char n    ,chars
  char n    char a    ,chars
  256       char z 1+ ,chars

: rot13-string ( addr len -- )
  over + swap do i c@ rot13 i c! loop ;

: .rot13" ( string -- )
  [char] " parse 2dup rot13-string type ;
 
.rot13" abjurer NOWHERE"   \ nowhere ABJURER

Fortran

Works with: Fortran version 90 and later
program test_rot_13

  implicit none
  integer, parameter :: len_max = 256
  integer, parameter :: unit = 10
  character (len_max) :: file
  character (len_max) :: fmt
  character (len_max) :: line
  integer :: arg
  integer :: arg_max
  integer :: iostat

  write (fmt, '(a, i0, a)') '(a', len_max, ')'
  arg_max = iargc ()
  if (arg_max > 0) then
! Encode all files listed on the command line.
    do arg = 1, arg_max
      call getarg (arg, file)
      open (unit, file = file, iostat = iostat)
      if (iostat /= 0) cycle
      do
        read (unit, fmt = fmt, iostat = iostat) line
        if (iostat /= 0) exit
        write (*, '(a)') trim (rot_13 (line))
      end do
      close (unit)
    end do
  else
! Encode standard input.
    do
      read (*, fmt = fmt, iostat = iostat) line
      if (iostat /= 0) exit
      write (*, '(a)') trim (rot_13 (line))
    end do
  end if

contains

  function rot_13 (input) result (output)

    implicit none
    character (len_max), intent (in) :: input
    character (len_max) :: output
    integer :: i

    output = input
    do i = 1, len_trim (output)
      select case (output (i : i))
      case ('A' : 'M', 'a' : 'm')
        output (i : i) = char (ichar (output (i : i)) + 13)
      case ('N' : 'Z', 'n' : 'z')
        output (i : i) = char (ichar (output (i : i)) - 13)
      end select
    end do

  end function rot_13

end program test_rot_13

Note: iargc and getarg are common extensions that are implemented by e.g. the Intel Fortran Compiler, G95 and gfortran.

Sample usage:

> cat foo.txt
foo
> cat bar.txt
bar
> ./rot_13 foo.txt bar.txt
sbb
one
> ./rot_13 < foo.txt
sbb
> cat foo.txt bar.txt | ./rot_13
sbb
one

FreeBASIC

' FB 1.05.0 Win64

' uses in place encoding/decoding
Sub rot13(ByRef s As String)
  If s = "" Then Exit Sub
  Dim code As Integer
  For i As Integer = 0 To Len(s) - 1    
    Select Case As Const s[i]
      Case 65 To 90  '' A to Z
        code = s[i] + 13
        If code > 90 Then code -= 26
        s[i] = code
      Case 97 To 122 '' a to z 
        code = s[i] + 13
        If code > 122 Then code -= 26
        s[i] = code
     End Select 
  Next
End Sub

Dim s As String = "nowhere ABJURER"
Print "Before encoding : "; s
rot13(s)
Print "After encoding  : "; s
rot13(s)
Print "After decoding  : "; s
Print
Print "Press any key to quit"
Sleep
Output:
Before encoding : nowhere ABJURER
After encoding  : abjurer NOWHERE
After decoding  : nowhere ABJURER

FunL

import io.{lines, stdin}

def rot13( s ) =
  buf = StringBuilder()

  for c <- s
    if isalpha( c )
      n = ((ord(c) and 0x1F) - 1 + 13)%26 + 1

      buf.append( chr(n or (if isupper(c) then 64 else 96)) )
    else
      buf.append( c )

  buf.toString()

def rot13lines( ls ) =
  for l <- ls
    println( rot13(l) )

if _name_ == '-main-'
  if args.isEmpty()
    rot13lines( stdin() )
  else
    for f <- args
      rot13lines( lines(f) )

GAP

rot13 := function(s)
  local upper, lower, c, n, t;
  upper := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  lower := "abcdefghijklmnopqrstuvwxyz";
  t := [ ];
  for c in s do
    n := Position(upper, c);
    if n <> fail then
      Add(t, upper[((n+12) mod 26) + 1]);
    else
      n := Position(lower, c);
      if n <> fail then
        Add(t, lower[((n+12) mod 26) + 1]);
      else
        Add(t, c);
      fi;
    fi;
  od;
  return t;
end;

a := "England expects that every man will do his duty";
# "England expects that every man will do his duty"
b := rot13(a);
# "Ratynaq rkcrpgf gung rirel zna jvyy qb uvf qhgl"
c := rot13(b);
# "England expects that every man will do his duty"

Gema

/[a-mA-M]/=@int-char{@add{@char-int{$1};13}}
/[n-zN-Z]/=@int-char{@sub{@char-int{$1};13}}

GML

#define rot13
var in, out, i, working;
in = argument0;
out = "";
for (i = 1; i <= string_length(in); i += 1)
    {
    working = ord(string_char_at(in, i));
    if ((working > 64) && (working < 91))
        {
        working += 13;
        if (working > 90)
            {
            working -= 26;
            }
        }
    else if ((working > 96) && (working < 123))
        {
        working += 13;
        if (working > 122) working -= 26;
        }
    out += chr(working);
    }
return out;

The above code is called like this:

show_message(rot13("My dog has fleas!"));

Output (in a message box):

Zl qbt unf syrnf!

Go

package main

import (
    "fmt"
    "strings"
)

func rot13char(c rune) rune {
    if c >= 'a' && c <= 'm' || c >= 'A' && c <= 'M' {
        return c + 13
    } else if c >= 'n' && c <= 'z' || c >= 'N' && c <= 'Z' {
        return c - 13
    }
    return c
}

func rot13(s string) string {
    return strings.Map(rot13char, s)
}

func main() {
    fmt.Println(rot13("nowhere ABJURER"))
}

Output:

abjurer NOWHERE

Golo

#!/usr/bin/env golosh
----
This module encrypts strings by rotating each character by 13.
----
module Rot13

augment java.lang.Character {

  function rot13 = |this| -> match {
    when this >= 'a' and this <= 'z' then charValue((this - 'a' + 13) % 26 + 'a')
    when this >= 'A' and this <= 'Z' then charValue((this - 'A' + 13) % 26 + 'A')
    otherwise this
  }
}

augment java.lang.String {

  function rot13 = |this| -> vector[this: charAt(i): rot13() foreach i in [0..this: length()]]: join("")
}

function main = |args| {

  require('A': rot13() == 'N', "A is not N")
  require("n": rot13() == "a", "n is not a")
  require("nowhere ABJURER": rot13() == "abjurer NOWHERE", "nowhere is not abjurer")

  foreach string in args {
    print(string: rot13())
    print(" ")
  }
  println("")
}

Groovy

Solution:

def rot13 = { String s ->
    (s as List).collect { ch ->
        switch (ch) {
            case ('a'..'m') + ('A'..'M'):
                return (((ch as char) + 13) as char)
            case ('n'..'z') + ('N'..'Z'):
                return (((ch as char) - 13) as char)
            default:
                return ch
        }
    }.inject ("") { string, ch -> string += ch}
}

Test program:

println rot13("Noyr jnf V, 'rer V fnj Ryon.")

Output:

Able was I, 'ere I saw Elba.

GW-BASIC

10 INPUT "Enter a string: ",A$
20 GOSUB 50
30 PRINT B$
40 END
50 FOR I=1 TO LEN(A$)
60 N=ASC(MID$(A$,I,1))
70 E=255
80 IF N>64 AND N<91 THEN E=90   ' uppercase
90 IF N>96 AND N<123 THEN E=122 ' lowercase
100 IF E<255 THEN N=N+13
110 IF N>E THEN N=N-26
120 B$=B$+CHR$(N)
130 NEXT
140 RETURN

Haskell

Straightforward implementation by checking multiple cases:

import Data.Char (chr, isAlpha, ord, toLower)
import Data.Bool (bool)

rot13 :: Char -> Char
rot13 c
  | isAlpha c = chr $ bool (-) (+) ('m' >= toLower c) (ord c) 13
  | otherwise = c

-- Simple test
main :: IO ()
main = print $ rot13 <$> "Abjurer nowhere"

Or in point-free applicative terms:

import Data.Char (chr, isAlpha, ord, toLower)
import Data.Bool (bool)

rot13 :: Char -> Char
rot13 =
  let rot = flip ((bool (-) (+) . ('m' >=) . toLower) <*> ord)
  in (bool <*> chr . rot 13) <*> isAlpha

-- Simple test
main :: IO ()
main = print $ rot13 <$> "Abjurer nowhere"
Output:
"Nowhere abjurer"

To wrap rot13 as a utility program, here's a quick implementation of a general framework:

import System.Environment
import System.IO
import System.Directory
import Control.Monad

hInteract :: (String -> String) -> Handle -> Handle -> IO ()
hInteract f hIn hOut =
  hGetContents hIn >>= hPutStr hOut . f

processByTemp :: (Handle -> Handle -> IO ()) -> String -> IO ()
processByTemp f name = do
  hIn <- openFile name ReadMode
  let tmp = name ++ "$" 
  hOut <- openFile tmp WriteMode
  f hIn hOut
  hClose hIn
  hClose hOut
  removeFile name
  renameFile tmp name

process :: (Handle -> Handle -> IO ()) -> [String] -> IO ()
process f [] = f stdin stdout
process f ns = mapM_ (processByTemp f) ns

Then the wrapped program is simply

main = do
 names <- getArgs
 process (hInteract (map rot13)) names

Note that the framework will read the file lazily, which also provides buffering.

HicEst

CHARACTER c, txt='abc? XYZ!', cod*100

  DO i = 1, LEN_TRIM(txt)
    c = txt(i)
    n = ICHAR(txt(i))
    IF( (c >= 'a') * (c <= 'm') + (c >= 'A') * (c <= 'M') ) THEN
        c = CHAR( ICHAR(c) + 13 )
    ELSEIF( (c >= 'n') * (c <= 'z') + (c >= 'N') * (c <= 'Z') ) THEN
        c = CHAR( ICHAR(c) - 13 )
    ENDIF

    cod(i) = c
  ENDDO

  WRITE(ClipBoard, Name) txt, cod ! txt=abc? XYZ!; cod=nop? KLM!;
END

Icon and Unicon

procedure main(arglist)
   file := open(arglist[1],"r") | &input
   every write(rot13(|read(file)))
end

procedure rot13(s)   #: returns rot13(string)
static a,n
initial {
   a := &lcase || &ucase
   (&lcase || &lcase) ? n := ( move(13), move(*&lcase) )
   (&ucase || &ucase) ? n ||:= ( move(13), move(*&ucase) )
   }
return map(s,a,n)
end

This example uses a number of Icon features.

  • alternation ( x | y ) selects and opens a file if supplied or fall back to standard output
  • repeated alternation ( |x ) is used to generate the contents of the input file
  • the rot13 procedure does a one time setup (initially) of persistent (static) mapping strings so the procedure can return the rot13 mapping
  • the setup exploits the ordered cset variables &lcase and &ucase coercing them into strings
  • the rot13 mapping string is then aggregated with strings taken by offsetting into double length values to avoid unnecessary and messy rotation

IS-BASIC

100 PROGRAM "Rot13.bas"
110 DO
120   LINE INPUT PROMPT "Line: ":LINE$
130   PRINT ROT13$(LINE$)
140 LOOP UNTIL LINE$=""
150 DEF ROT13$(TEXT$)
160   LET RESULT$=""
170   FOR I=1 TO LEN(TEXT$)
180     LET CH$=TEXT$(I)
190     SELECT CASE CH$
200     CASE "A" TO "M","a" TO "m"
210       LET CH$=CHR$(ORD(CH$)+13)
220     CASE "N" TO "Z","n" TO "z"
230       LET CH$=CHR$(ORD(CH$)-13)
240     CASE ELSE
250     END SELECT
260     LET RESULT$=RESULT$&CH$
270   NEXT
280   LET ROT13$=RESULT$
290 END DEF

J

rot13=: {&((65 97+/~i.2 13) |.@[} i.256)&.(a.&i.)

For example:

   rot13 'abc! ABC!'
nop! NOP!

Compare with the solution to the Change String Case task.

Java

import java.io.*;

public class Rot13 {

    public static void main(String[] args) throws IOException {
        if (args.length >= 1) {
            for (String file : args) {
                try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
                    rot13(in, System.out);
                }
            }
        } else {
            rot13(System.in, System.out);
        }
    }

    private static void rot13(InputStream in, OutputStream out) throws IOException {
        int ch;
        while ((ch = in.read()) != -1) {
            out.write(rot13((char) ch));
        }
    }

    private static char rot13(char ch) {
        if (ch >= 'A' && ch <= 'Z') {
            return (char) (((ch - 'A') + 13) % 26 + 'A');
        }
        if (ch >= 'a' && ch <= 'z') {
            return (char) (((ch - 'a') + 13) % 26 + 'a');
        }
        return ch;
    }
}

JavaScript

function rot13(c) {
    return c.replace(/([a-m])|([n-z])/ig, function($0,$1,$2) {
        return String.fromCharCode($1 ? $1.charCodeAt(0) + 13 : $2 ? $2.charCodeAt(0) - 13 : 0) || $0;
    });
}
rot13("ABJURER nowhere") // NOWHERE abjurer

TDD with Jasmine using Underscore.js

function rot13(value){
  if (!value)
    return "";

  function singleChar(c) {
    if (c.toUpperCase() < "A" || c.toUpperCase() > "Z")
      return c;

    if (c.toUpperCase() <= "M")
      return String.fromCharCode(c.charCodeAt(0) + 13);

    return String.fromCharCode(c.charCodeAt(0) - 13);  
  }

  return _.map(value.split(""), singleChar).join("");
}

describe("Rot-13", function() {
  it("Given nothing will return nothing", function() {
    expect(rot13()).toBe("");
  });

  it("Given empty string will return empty string", function() {
    expect(rot13("")).toBe("");
  });

  it("Given A will return N", function() {
    expect(rot13("A")).toBe("N");
  });

  it("Given B will return O", function() {
    expect(rot13("B")).toBe("O");
  });

  it("Given N will return A", function() {
    expect(rot13("N")).toBe("A");
  });

  it("Given Z will return M", function() {
    expect(rot13("Z")).toBe("M");
  });

  it("Given ZA will return MN", function() {
    expect(rot13("ZA")).toBe("MN");
  });

  it("Given HELLO will return URYYB", function() {
    expect(rot13("HELLO")).toBe("URYYB");
  });

  it("Given hello will return uryyb", function() {
    expect(rot13("hello")).toBe("uryyb");
  });


  it("Given hello1 will return uryyb1", function() {
    expect(rot13("hello1")).toBe("uryyb1");
  });
});

jq

jq on the shebang line

#!/usr/bin/env jq -M -R -r -f
# or perhaps:
#!/usr/local/bin/jq -M -R -r -f

# If your operating system does not allow more than one option
# to be specified on the command line,
# then consider using a version of jq that allows
# command-line options to be squished together (-MRrf),
# or see the following subsection.

def rot13:
  explode
 | map( if 65 <= . and . <= 90 then ((. - 52) % 26) + 65
        elif 97 <= . and . <= 122 then (. - 84) % 26 + 97
        else .
   end)
 | implode;

rot13

bash on the shebang line

#!/bin/bash

jq -M -R -r '

def rot13:
  explode
 | map( if 65 <= . and . <= 90 then ((. - 52) % 26) + 65
        elif 97 <= . and . <= 122 then (. - 84) % 26 + 97
        else .
   end)
 | implode;

rot13'

Example:

$ echo abc123ABC | ./rot13
nop123NOP

Jsish

rot13 function borrowed from Javascript entry, and modified to take into account typed parameters to functions in Jsish.

Can be used as a require module or a command line utility, and includes unit testing.

#!/usr/local/bin/jsish
/* ROT-13 in Jsish */
function rot13(msg:string) {
    return msg.replace(/([a-m])|([n-z])/ig, function(m,p1,p2,ofs,str) {
        return String.fromCharCode(
            p1 ? p1.charCodeAt(0) + 13 : p2 ? p2.charCodeAt(0) - 13 : 0) || m;
    });
}
provide('rot13', Util.verConvert("1.0"));

/* rot13 command line utility */
if (isMain()) {
    /* Unit testing */
    if (Interp.conf('unitTest') > 0) {
;       rot13('ABJURER nowhere 123!');
;       rot13(rot13('Same old same old'));
        return;
    }

    /* rot-13 of data lines from given filenames or stdin, to stdout */
    function processFile(fname:string) {
        var str;
        if (fname == "stdin") fname = "./stdin";
        if (fname == "-") fname = "stdin";
        var fin = new Channel(fname, 'r');
        while (str = fin.gets()) puts(rot13(str));
        fin.close();
    }

    if (console.args.length == 0) console.args.push('-');
    for (var fn of console.args) {
        try { processFile(fn); } catch(err) { puts(err, "processing", fn); }
    }
}

/*
=!EXPECTSTART!=
rot13('ABJURER nowhere 123!') ==> NOWHERE abjurer 123!
rot13(rot13('Same old same old')) ==> Same old same old
=!EXPECTEND!=
*/
Output:
prompt$ jsish -e 'require("rot13"); puts(rot13("abcxyz"));'
nopklm

prompt$ jsish -u rot13.jsi
[PASS] rot13.jsi

prompt$ jsish rot13.jsi
this is a stdin filter test
guvf vf n fgqva svygre grfg

prompt$ ./rot13.jsi rot13.jsi | head -4
#!/hfe/ybpny/ova/wfvfu

/* EBG-13 va Wfvfu */
shapgvba ebg13(zft:fgevat) {

prompt$ ./rot13.jsi rot13.jsi | head -4 | ./rot13.jsi
#!/usr/local/bin/jsish

/* ROT-13 in Jsish */
function rot13(msg:string) {

Julia

# Julia 1.0
function rot13(c::Char)
    shft = islowercase(c) ? 'a' : 'A'
    isletter(c) ? c = shft + (c - shft + 13) % 26 : c
end

rot13(str::AbstractString) = map(rot13, str)
Output:
julia> rot13("abcdefghijklmnopqrtuvwxyz 123 ABCDEFGHIJKLMNOPQRTUVWXYZ")
"nopqrstuvwxyzabcdeghijklm 123 NOPQRSTUVWXYZABCDEGHIJKLM"

Alternative version

replace("nowhere ABJURER", r"[A-Za-z]" => s -> map(c -> c + (uppercase(c) < 'N' ? 13 : -13), s))
Output:
abjurer NOWHERE

K

  rot13: {a:+65 97+\:2 13#!26;_ci@[!256;a;:;|a]_ic x}

  rot13 "Testing! 1 2 3"
"Grfgvat! 1 2 3"

Kotlin

import java.io.*

fun String.rot13() = map {
    when {
        it.isUpperCase() -> { val x = it + 13; if (x > 'Z') x - 26 else x }
        it.isLowerCase() -> { val x = it + 13; if (x > 'z') x - 26 else x }
        else -> it
    } }.toCharArray()

fun InputStreamReader.println() =
        try { BufferedReader(this).forEachLine { println(it.rot13()) } }
        catch (e: IOException) { e.printStackTrace() }

fun main(args: Array<String>) {
    if (args.any())
        args.forEach { FileReader(it).println() }
    else
        InputStreamReader(System.`in`).println()
}

Ksh

#!/bin/ksh

# rot-13 function

#	# Variables:
#
integer ROT_NUM=13			# Generalize to any ROT

string1="A2p"				# Default "test"
string=${1:-${string1}}		# Allow command line input

typeset -a lcalph=( a b c d e f g h i j k l m n o p q r s t u v w x y z )
typeset -a ucalph=( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )

#	# Functions:
#
#	# Function _rotN(char) - return the "rotated" N letter to char
# Needs: $ROT_NUM defined
#
function _rotN {
	typeset _char ; _char="$1"
	typeset _casechk _alpha _oldIFS _buff _indx

	[[ ${_char} != @(\w) || ${_char} == @(\d) ]] && echo "${_char}" && return	# Non-alpha

	typeset -l _casechk="${_char}"
	[[ ${_casechk} == "${_char}" ]] && nameref _aplha=lcalph || nameref _aplha=ucalph

	_oldIFS="$IFS" ; IFS='' ; _buff="${_aplha[*]}" ; IFS="${oldIFS}"
	_indx=${_buff%${_char}*}
	echo ${_aplha[$(( (${#_indx}+ROT_NUM) % (ROT_NUM * 2) ))]}
	typeset +n _aplha
	return
}

 ######
# main #
 ######

for ((i=0; i<${#string}; i++)); do
	buff+=$(_rotN "${string:${i}:1}")
done

print "${string}"
print "${buff}"
Output:

A real 12 test

N erny 12 grfg

LabVIEW

This image is a VI Snippet, an executable image of LabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.
LabVIEW Rot-13.png

Lambdatalk

The rot13 function works on any text containing this set

abcdefghijklomnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXZ.

Note that spaces can be used but not the "_" character used to handle them.

{def rot13

 {def rot13.alphabet {A.split 
 abcdefghijklomnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXZ_.}}

 {def rot13.delta
  {lambda {:i :a}
   {A.get {% {+ {A.in? {A.get :i :a} {rot13.alphabet}}
                32} 64} {rot13.alphabet}}}}
 {def rot13.r
  {lambda {:a :b :n :i}
   {if {> :i :n}
    then :b
    else {rot13.r :a 
                  {A.set! :i {rot13.delta :i :a} :b}         
                  :n {+ :i 1}} }}}

 {lambda {:txt}
  {let { {:t {S.replace \s by _ in :txt}} }
   {S.replace _ by space in 
    {A.join {rot13.r {A.split :t} 
                     {A.new}
                     {- {W.length :t} 1} 
                     0 }}}}}}
-> rot13

1) encoding:
 
{rot13 abcdefghijklomnopqrstuvwxyz 
       0123456789 
       ABCDEFGHIJKLMNOPQRSTUVWXZ.}
-> 56789ABCDEFGKIJKLMNOPQRSTUV3WXZ .abcde3fghijklomnopqrstuvwxyz0124

2) decoding:

{rot13 56789ABCDEFGKIJKLMNOPQRSTUV3WXZ .abcde3fghijklomnopqrstuvwxyz0124} 
-> abcdefghijklomnopqrstuvwxyz 0123456789 ABCDEFGKIJKLMNOPQRSTUVWXZ.

Lasso

// Extend the string type

define string->rot13 => {
    local(
        rot13 = bytes,
        i, a, b
    )

    with char in .eachCharacter
    let int = #char->integer
    do {
        // We only modify these ranges, set range if we should modify
        #int >= 65 and #int < 91  ? local(a=65,b=91)  |
        #int >= 97 and #int < 123 ? local(a=97,b=123) | local(a=0,b=0)
   
        if(#a && #b) => {
            #i = (#int+13) % #b         // loop back if past ceiling (#b)
            #i += #a * (1 - #i / #a)    // offset if below floor (#a)
            #rot13->import8bits(#i)     // import the new character
        else
            #rot13->append(#char)       // just append the character
        }
    }

    return #rot13->asstring
}
Example
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'->rot13

'Where do you find a dog with no legs?
Evtug jurer lbh yrsg uvz.'->rot13
Output:
NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm

Jurer qb lbh svaq n qbt jvgu ab yrtf? 
Right where you left him.
Another implementation
define rot13(p::string) => {
    local(
        rot13 = bytes,
        a = bytes('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'),
        b = bytes('NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'),
        i
    )

    with char in #p->eachCharacter 
    let c = bytes(#char) do {
        #i = #a->find(#b)
        #i ? #rot13->import8bits(#b->get(#i)) | #rot13->append(#c)
    }
    
    return #rot13->asString
}

rot13('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
Output:
NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm

Liberty BASIC

Liberty BASIC string comparisons are not ascii-based. Verbose version:

input "Type some text to be encoded, then ENTER. ";tx$

tex$ = Rot13$(tx$)
print tex$
'check
print Rot13$(tex$)

wait

Function Rot13$(t$)
    if t$="" then
        Rot13$=""
        exit function
    end if
    for i = 1 to len(t$)
        c$=mid$(t$,i,1)
        ch$=c$
        if (asc(c$)>=asc("A")) and (asc(c$)<=asc("Z")) then
            ch$=chr$(asc(c$)+13)
            if (asc(ch$)>asc("Z")) then ch$=chr$(asc(ch$)-26)
        end if
        if (asc(c$)>=asc("a")) and (asc(c$)<=asc("z")) then
            ch$=chr$(asc(c$)+13)
            if (asc(ch$)>asc("z")) then ch$=chr$(asc(ch$)-26)
        end if
        rot$=rot$+ch$
    next
    Rot13$=rot$
    end function

Concise:

Function Rot13$(t$)
    for i = 1 to len(t$)
        ch$=mid$(t$,i,1)
        if (asc(ch$)>=asc("A")) and (asc(ch$)<=asc("Z")) then
            ch$=chr$(asc("A")+ (asc(ch$)-asc("A")+13) mod 26)
        end if
        if (asc(ch$)>=asc("a")) and (asc(ch$)<=asc("z")) then
            ch$=chr$(asc("a")+ (asc(ch$)-asc("a")+13) mod 26)
        end if
        Rot13$=Rot13$+ch$
    next
    end function

Limbo

A fairly straightforward version that uses a lookup table, based on Inferno's cat(1).

implement Rot13;

include "sys.m"; sys: Sys;
include "draw.m";

Rot13: module
{
	init:	fn(ctxt: ref Draw->Context, argv: list of string);
};

stdout: ref Sys->FD;
tab: array of int;

init(nil: ref Draw->Context, args: list of string)
{
	sys = load Sys Sys->PATH;
	stdout = sys->fildes(1);
	inittab();
	args = tl args;
	if(args == nil)
		args = "-" :: nil;
	for(; args != nil; args = tl args){
		file := hd args;
		if(file != "-"){
			fd := sys->open(file, Sys->OREAD);
			if(fd == nil){
				sys->fprint(sys->fildes(2), "rot13: cannot open %s: %r\n", file);
				raise "fail:bad open";
			}
			rot13cat(fd, file);
		}else
			rot13cat(sys->fildes(0), "<stdin>");
	}
}

inittab()
{
	tab = array[256] of int;
	for(i := 0; i < 256; i++)
		tab[i] = i;

	for(i = 'a'; i <= 'z'; i++)
		tab[i] = (((i - 'a') + 13) % 26) + 'a';
	for(i = 'A'; i <= 'Z'; i++)
		tab[i] = (((i - 'A') + 13) % 26) + 'A';
}


rot13(s: string): string
{
	for(i := 0; i < len s; i++) {
		if(s[i] < 256)
			s[i] = tab[s[i]];
	}
	return s;
}

rot13cat(fd: ref Sys->FD, file: string)
{
	buf := array[Sys->ATOMICIO] of byte;

	while((n := sys->read(fd, buf, len buf)) > 0) {
		obuf := array of byte (rot13(string buf));
		if(sys->write(stdout, obuf, n) < n) {
			sys->fprint(sys->fildes(2), "rot13: write error: %r\n");
			raise "fail:write error";
		}
	}
	if(n < 0) {
		sys->fprint(sys->fildes(2), "rot13: error reading %s: %r\n", file);
		raise "fail:read error";
	}
}

LiveCode

function rot13 S
   repeat with i = 1 to length(S)
      get chartonum(char i of S)
      if it < 65 or it > 122 or (it > 90 and it < 97) then next repeat 
      put char it - 64 of "NOPQRSTUVWXYZABCDEFGHIJKLM      nopqrstuvwxyzabcdefghijklm" into char i of S
   end repeat
   return S
end rot13

Locomotive Basic

10 INPUT "Enter a string: ",a$
20 GOSUB 50
30 PRINT b$
40 END
50 FOR i=1 TO LEN(a$)
60 n=ASC(MID$(a$,i,1))
70 e=255
80 IF n>64 AND n<91 THEN e=90   ' uppercase
90 IF n>96 AND n<123 THEN e=122 ' lowercase
100 IF e<255 THEN n=n+13
110 IF n>e THEN n=n-26
120 b$=b$+CHR$(n)
130 NEXT
140 RETURN

to rot13 :c
  make "a difference ascii lowercase :c  ascii "a
  if or :a < 0 :a > 25 [output :c]
  make "delta ifelse :a < 13 [13] [-13]
  output char sum :delta ascii :c
end

print map "rot13 "|abjurer NOWHERE|
nowhere ABJURER

Lua

function rot13(s)
	local a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
	local b = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
	return (s:gsub("%a", function(c) return b:sub(a:find(c)) end))
end

Alternative version

function rot13(s)
  return (s:gsub("%a", function(c) c=c:byte() return string.char(c+(c%32<14 and 13 or -13)) end))
end


Malbolge

b'BA@?>=<;:9876543210/.-,+*)('&%$#"!Q=+^:('&Y$#m!1So.QOO=v('98$65a`_^]\[ZYXWVUTSRQ#I2MLKJIHGFE
DCBA@#!7~|4{y1xv.us+rp(om%lj"ig}fd"cx``uz]rwvYnslkTonPfOjiKgJeG]\EC_X]@[Z<R;VU7S6QP2N1LK-I,GF(
D'BA#?>7~;:9y16w43s10)p-,l*#(i&%e#d!~``{tyxZpuXsrTTongOkdMhg`Hd]ba`_^W@[ZYXW9UNSRQPOHMLKJ-++FE
''<A$?>=<;:387xw43s10/(-&m*)('&}${d!~}|^zyxwvutmVqpiRQlkjiKafedc\E`_^@\[ZYX;V9NMRQ42NGLK.IH*F?
DCBA$#>7~;{{8xx5uu2rr/oo,ll)ii&f|e"!aw`{z\r[vXnmVTpongPkNihgJ_dcFa`B^]\UZ=RWV8TSLQ4ON0LE.IHA)E
>'BA:?!7~5|38y6/v321q).-&m*)i'&%|{d!~}_{zs\wvutsUqTonPlOjiKgJedFbE`_A]@[Z<X;VU7S6QP22GL/JIB+FE
DC%;@?>7~;:987w5v32r0)p-,+k)('~g$#"b~w|uz]xwvutsrqTinQlOjLhgfeH]bE`CB]\>ZSXWVUTSRQPON1LE.I,+*(
(&&$$""~~||zzxxv4u210/(-n+l)ji~g|eccaa_{zy[qZoXVVTponPfOdiLJJ_HFba`BXAV?==;;9977pQPONMLKJIHGFE
DCBA@?>=<;:9876543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcF!`_^]\[ZYXWVUTSRQPONMLKJIHGFE
DCBA@?>=<;:9876543210/.-JI*)FE&%$#"!~}|{zyxwvutsrqponmlkjihgJ%dcF!`_^]\[ZYXWVUTSRQPO2kLKJIHGF)
bCBA@?>=<;:9876543210/.-JI*)FE3%$#"!~}|{zyxwvutsrqponmlkjihgJ%dcF!`_B{\[>wXWVUTSRQPO2kLKJIHGF)
bCBA@?>=<;:9876543210/.-JI*)FE&%$#"!~}|{zyxwvutsrqponmlkjihgJ%dcF!`_B{\[ZYX;VUTS6Q4O200EJIH*@)
>'%A@?!7~5|zzx65u3,s*qoommk)(h&}f{dbb``^^\xwYutWVkToRmlkjMLgfHdcF[DBB@\?==RWV8TM6K4220LK-IB+@E
(&&;$""~~||zzxxv4u21r/.o,mlk"i&g$#"!b}`{^\\qvYWWlUSSQQOkjiKaJ_HFFD`_A]V?T=;;997SRQ3I2G0.JIH*@)
>'%A@">=~}4{8y6wv3trr).omm$)j'&g$#d!ba`u^y\wZYtWrqTonmOOdihK`IHG\a`_AW@U><XWV8N7LQ422G0.JI+G@)
>C&$$9"~~||z87w5.u,sqqoommkki'h%$e"yb}`_t][wvXtmVkpSQQfOMihgI_H]FD`_A]V?T=;;99775QPO1G0E.,HG)E
>'<A$""7~||z8y654u,s0qp',m*)ii&}$e"cb``^z][[putVrkTiRPPNjMKK`edFb[DYB@\?==RWVU7M6K42200..,,*F)
DCB%@9>!~;|zz165u32s*qoommkki'&f${dy~a__t][[YutVrkTinQOOdMKKIIGGEaD_^A\?ZYR;:U8SR533NMLEJ-,G*(
(=B%##8=<|:3z1xvvttr0/o-&m$)jhh}fd"!~`v_t][wvXtmVkpSQQfOMMKKIIGGEaD_^A\?ZYXQV9T7R5PO11LKJIB+F)
D'%%:#!!};:z81x/vttrrppnnlljjhhf$e"!~a|{zyr[vYXmrqpRnQfkjiKaJ_HFF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UjSQQOkNLLafeGc\EZCAA??==;W:88MRQ3OH1F/--++))
'C&$$9>!<;:{8765.u2sr)p'nlljjhhffddb~}_{t]r[YYWWUUSoRmlkdMhKJ_dcbDZCX]@>>S<::8866442200..,,**(
D'BA@9"=~}4{27x54tt+0q.onlljjhhf$#c!xav_]][[YYWWUUSoRmlkNchKJeHcbECC^W@?Z=;;PUT6RK4I200..,,**(
(&&$$""~~|:{87x5v3,s0q.o,+kk('~%f#d!b``uz][[pYnsVTTinQlkjMhg`eHGF[`C^]@>>YXWP98SR4PO2G0..,,*FE
'C<%:#!!}}{{yywwuus1r/.o,m*)(!h%f#d!~``{zyxqvYtWVkTinQOOdihJf_H]FD`CAAV[Z<XQ:O8664PO1MF/D-++))
''%%##!!};|987x5432+0q.o,mkk"'&f$#dybw|_zyxqZuXWlqTonmfOjMhKfeGG\E`C^A??T=R;997S644INM/KD-B+)E
D&B;$9"~~||zzxxvvttr0q.-,m$kji~%f#"caa|uz]\wZXXmrqSonQfOMihJf_H]FDDBB@\[=YR;PU866K4220LK-IB+@E
(&&;$""~~||z8y65v3t1*/p-n+l)(hh%${d!bav{^\\qZXtWUUjonPleNcLJJHdcbDZCXA??==;;9977553O2MLK.IHA*)
D'BA$""=<;49zyx/v-trrppnnl*)i'~g|eccaa__]][[YuXsrUpSnmlejMLgJedGEE`_^]V?>YX:VU8MRQ3OH1FK.,,A*(
D'%%:?>~<5|3zx6wuu,10p.'n%ljjhhffd"caav{z\xqZoXVVTTRRPlOMMbgJedGbE`_^]V?Z=X;VUTSR44INM0E.I,+@E
(&&;@?>~6}4{y765u-t+rppnnllj('g%|ezcaa__]][[YuXsrqjSRmPkjMKK`eHGbECCXAV?==;W:88MRQ3OH1F/-I,**?
DC%A:#8!};:9y1x/vttrrppnnllj(i&%f#dy~a`{zy[wZoXmVTTRRPlkMibK`eHFF[DBB@\[=YR;PU866K42NM/KD-BG*(
(=&$$""~~|:{87x5v3,sr/p-,mkk('~%fedybw`^zy[wpYnsVTTiRPPNNLLJfeGc\EZCAA??==;;9U8SR5P3NMFK.I,+@E
(CB$$?>=6}:{zxxv432r*q(ommkki'&%e{dy~a__t][[YYWWUUSoRmlkNihg`IdGbE`_AA\[ZYRW:U87LQ422G0.JIH*@)
>'%%##!!}}{{yywwuus1r/.-n+*)(!&gf#d!~a|{z\\qvuXmVUpSQQfOMihgI_H]bECCXA??=YX:VO8M6442200..,,**(
D'BA$?8!~}49z76wuu,sr/pnn%l#(igg|#d!~a|_t]x[ZotWrqSSnglOjMhgIedG\ECCA]@>>SXW9UN7L53311//--++))
''%A$""7<}:98y6/4uts*q(o&+l)(igg$#zcb}`^^sxwYunWlUSSQQOOMiLJJ_dcEaZCXA??=YX:VO8MR533H1//--++)E
(CB%@#>=6}:{8y65uu210).o,m*kii~%fddy~}_{t]r[YYWWUUSSQmlNjcLaJHHFFDDBB@\?ZYX;VUTMR543HM0KJ-++FE
DC<%$#!!};:z81x/4uss*qoommk)('g}f{dbb``^^\\ZvYtsVqTonmleNiLgJedcbaCCX]\?T=X;:O86RQP2H1FK.,,A*(
DCB$:#8!};:z81x/vttrrppnnlljjh&g$#"yba`u^sx[vuXVVkpSRmlNjcLaJHHFFDDBB@@>><<::886R5PO2M0EJ-,+@E
(CB%##>7~}:98x0w.ussq/.n,%l#(igg|ec!~`|u^sx[YYnWUqpoQgPejMKK`IGGEECCAA??=Y<WV9T7RK4O21FK.IH**E
D=B%@#>=};:{27xvv-2s0/.o,+$)j'h%f#"bb}|{t]x[vYWWlUSSQQOkjLhaJ_HFFDDBB@@>><<:V9TSR5PONG0K.I,GF(
(CBA@9>!<}|38yww.us10/o'n%ljjh&%$dzcxa_{^\\qvuWslUjSQQOkjLhaJ_dGEEZCAA??==;W:UTS6QPONGL/.I,GF)
DCB$$9>=~5|{8yww.ussqqo-,l*#j!&geezcaa_{z\xqZoXVVTTRRPPNjMhgJe^GbEDY^A\[==R;V9866442N1//DIH*F?
(=&$$">=<|4{2ywwuussqqo-n+*)j!hg$e"!b``{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ywwuus10p.'n%*kii~geec!~`|u^s\ZZXXVVTTRnQlkjMhaJIH]bE`_B@@[ZSX;:U866KPO1ML/D-++))
''%%##!=<|:3z16wuu,sqqoommk)j'&g$e"!x}`{^y\wvXXsrqjSnQlOMMbgJHH]FDDB^A??TYX:VO8M6442200..,,**(
(&B%@?>!<;:3z7x5v32rr/.-,%*k(i&geez!b``u^s\ZvuWslUjSQmlNjcLafIGG\EC_^@\U>SX;99N7553311//--++)E
(CBA$?>=<5:{8yx/432r0q(-n+*)"i&gf{"!~`v_ty\ZZoXVVTTRRPPNNLLJJHHFFD`C^]\U>=X;VU866K43N1//D-+GF(
D=&;@#!!6}{98x6/v-trrppnnlljjhhffd"c~}`{^s\wZuXsrTTohmPkNiLJJ_H]FD`_A]V?T=;;9UT6RK4IN1//D-++))
''%%##!!};|987x5.3t1rq(-nll#j!&g$#"c~}v_^]rwZutWUUponglONMKKIeHFF[`_A]V?T=;WV8TM6K42N1//DIH*F?
(=&$$""~~||zzx6w43t1r/.-&+l)ji~%f#"bb}|{zs\wZuXVVkpoQmlOdihJf_H]FDDBB@@>><<::8866442N1LKJ-HGFE
>'&A$?>!<;:zz165v-ts0/o-,m$)jhh}$#c!xav_]][[YYWsrTpiRglOMMbKIIGGEECCAA?[>YX;VO876K4IN1LK.,,AF)
(C&$$9>=};:{27x54u2s*/p-nm$k"'h%$dd!xa|_z][[putVrqTinQlkjMhaJIH]bE`_B@@[ZSX;:9N7553ONM/E.C,*FE
'C<%:#!!}}{{yywwuus1r/.o,m*)"'hgf{"c~}`^^yxwpYXsVTTiRglOMMbgJedGbE`_^W@[>=RW:UT66QPONGL/J-,**(
(&BA#?8!6}{{yywwuussqqo-n+*)j'&%${"cb}`{z]xwvXXmrqTiRQPejiKg`I^cFDDYB@@>ZY;WP9NS644I20LK-IB+@E
(&&;$">=};4{27xvv-trrppnnlljjh&g$#d!xa`_ty\wvYWWlUTonPleNchKII^GEECCA]\>ZS<Q:8866442200..,H+FE
(C&;$#>=<|:{2765u-t+rppnnlljjh&%e#zcx}`^^s\ZvuWslUjoRPPeNLLJJHHFbE`_B]@[TY<;:OT7RQ422MLE.-H+))
>CB$@9"7~|:{yy054t2+r)pn,+k)"i~geeccaa_{zy[qZotWUUjSQQOOMMKgJedGbE`_XA@[>YX;99TSRKP32M0..CH+))
>'<%#?>=}5|3zx65u3,s*/pnn%ljjhhffddbb``^^\x[vuXsVqpohmPkNMbgJedFFa`_^W@[>YX:VU8MR533HM0KJI,GFE
D=&A$?"=<;:9yy054u,s0qp'n%lj(igg|#"b~w`u^\xwYunWlUSonPleNchKII^GEa`B^W@UZ=;;P977553311//-I,GFE
>'&A$?>!}}49zy6wuu,10p.-n%*kii~%f#"c~av{^]\qvYtsVTTohQPkNLLafeGc\EZCAA?[><<QVU7SL5J31ML.JC,A*(
(&&$$""~~||z8y65v3t1*qp-n+*kii&%|#dcbw|_]]r[YuXVVkpoQmfOdMKKIIGGEa`B^W@U><<::88664P3NM0K.IHAF)
('<A$""7~5:{87x5v321*qpo&+l)(i&g$#"!x}`{^y\wvutsUUjonQfOjMhKII^cbD`YBW@>Z=;;PUT6RK4I200..,,**(
(&&$$""~<}:981xw4uss*q(-n+*k(i~gfez!b}|_]]xqvYXsrTpiRglOMMbKIIGcFDDY^]?[T=R;9UT6RK4I200..,,**(
(&&$@#>=~;|927x5v3t10pp-,%l)j'hff{"!~`v_t][[YYWsrTpiRgPNNLLJfeGc\EZ_B@@U><<::886R5PON1LKD-,+@E
(CB%##>=<5:{z765u-t+rp.omm$)(h&}f{db~}|^t]r[YYWWUUSSQQOOMMKgJedGbE`_^W\?Z=<Q:OT7RQ33NMLKD-H+F)
''<A@?!7~5|zzxxv43s1*q(ommkkiiggeecca}`{zy\wvutmVUTiRglkjLbK`IGGEECCAA??==;;99775Q4ON1LE.-,AF)
DC&$$9>!~;:z87x/4uss*/p-,m*k"'h%f#d!~``{t]x[vYWWlUSonmOeNcLJJHHFFDDBB@@>><<:V9TSR5PI2M0/DI,**?
(=B%@?>!<;49z7xw.3t10/p-,+$k(ih}$e"!~a|{zyrwZYXmVkTinQOOdiLgfId]FEDY^]\>T=RW:88M6442200..,,**(
(&&$$">!<;|92y6w4uss*q(-n+*)j!h%fez!b}|^^yrwZuXsVTTinmOkdMbKIIGcFDDY^]?[T=R;9UT6RK4I200..,,**(
(&&$@#>=<}:38yxw.u,sqqoom+ljj!&%e#zcxa_{zy[qZoXVVTTRRPPNNLhKfeHcFa`YBA\?ZY<::UTSLQ43N1//DI,**?
(&&$$""~<;{92y0wuus10p.'n%*kii~geeccaa_{^yx[vYtsrkpSnQlOjiKKfedc\E`C^]?[Z=RWV8TM6KP311F/--++))
''%%##!!}}{{y7x543t10/.'n+l)j'&%$#ccx}|_t]x[vYWWlUSonPleNcLJJHdcEaZCX]@>>S<:VU7SL5JO200E.,,**(
(&&$$">!<;:3zy6w43trr).on+ljj!&geez!~`|u^sx[YYnWUUSSQQOOMMKKIIGGEEC_B]\?Z=RW:9T755JONM/E.C,**(
DCB$:#8!};:z81x/vttr0/o-&m$)jhh}fddbb``^^\x[vuXsVqjSRmPNNchKfeHFFa`Y^A@?TYX:VO8MR533H1/KJ,HA*?
D'%%:#!!}}{{yywwuussqqo-nll#(i&%f#d!~w|_z]\qZXtWUUjonmOeNcLJfedF\EZCAA??=YX:VO8M6442200..,H+FE
D'BA@9"!<}:9zxx5432+0qp-nll#jh&%e#zcx}`^^s\ZZXtsrTjShQOkjiKaJ_HFba`BXAV?==;;99775Q4ON1L/JIHG@E
('BA@">!6}{987w/v-trrppn,mkk"'&f${dyb``^^\\ZZXXVrUpoRmfONihJfeH]bECCX]\>ZS<Q:886R533HML.JC,A*(
(&&$$""~~||zzx6wuu,1r/.o,m$kj'h%$ecc~w|_^y\ZZotsUqjShmPNNcLJJHHFFDDBB@\[=YR;PU866K42200..,H+FE
(C&A:?"=~}498x65v-t+rppnnllj('&f|ezca}|{]s\qvYWWlUSSQQOOMMKgJedcFa`YB]@?TY<WV88SRQJO2M0/--+GF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ZY<::UTMR543H1F/--+G*(
(=BA#?8!6}{9zxx/43s1*q(ommkkiiggeecca}`^^sx[vuXsVqpinQlONchgIedG\EZ_B]\[>YXWP9T7R5PO11LKJIBG*E
('<%:#!!};|zz165u3,s*qoom+ljj!&%e#zcxa__]][[YYWWUqTRRglOjihKfedc\aD_B]@[ZYXW99NSR5J3N1LK-IH+@)
'CB$@9"7<}{{2ywwuussqqoommkkiig%f#"!xa`{^yx[YYnWVqTRRglkMibK`IGGEEC_^@\U>SX;99N7553311//--++)E
(CB%@#8!~;|98yww4-2sr/pnn%*kii~ge#"b~w`uz][[pYWWUUSSQQOOMMKKIIGcFa`C^A\UZ=<;PUTS5Q4IN1LK.I,GF?
(C&A$?>~~;:927x5v3trr)pnnllj('g%|ezca}`^^sxwYunWlUSSQQOOMMKKIeHcbaD_^]V[>=X;VU866QPONG0/.C,AF)
''<A@">7~5|zzx6wuu,10p.'n%lj('g%|ezcaa__]][[YYWWUqTonQlOjihg`IHcFa`C^]\>>SXW:O87R533HM0..C,A*(
(&BA@"8!6}{{y76v4-t+0qoo&mkkiiggeecca}`{z]xqZYtWrqTRRglONMbgJHH]ba`BXAV?==;;9UT6RK4IN1//D-++))
''%%##!!};|98y6w.3t1r/p-,ll)"i&g$eccx}|^zs\qZXXVVTTRRPPNNLLJJHHFbE`_^A\U>Y<;PU8SR44ONGL/J-H+))
>'<A$""7<}:98y65.3ts0q.-nll)('~gf#"b~}`uzy[wpYnWUqpRngPeNLLJJHdGEEZ_^@\U>S<::886644220L/JI,G*E
DC<%$?"=<}{{8765.3tsr).omm$)('g}f{dbb``^zyxZpYnWUqTRRglkMibK`IGGEa`B^W@UZ=;;P97755331M0KJ-H+FE
DC<A$?"!6}4{2yw543s+r).omm$kiigge#dbbw|{]yr[pYWWUUSSQQOOMiLgfe^GFaDBBW@U><<:VU7SL5JO200E.,,*FE
D&<%:#!!}}{{yywwu3t10q.o&ml)j'&gee"y~a`_ty\ZZoXVVTTRnQOOdihJf_H]FDDBB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ZZXXVVTpSnmPkNihgf_HGbE`_B]\[==RWV9N76QP2NM0E.,H+))
>CB$@9"7~||z8yww.32r0)p'nl*kii~%$d"ybw`^^\\ZZXXVVTpSQQfkNihKf_HcFEZ_B]\>>SX;V9T755JO2MLK.CH+F)
DC%A@#8!6;|zz165u3,s*qoommk)jhh}$#c!xav_]][[YutVrkTinQOOdMKKIIGGEaD_^]@[T=<W:UT755POHM0/J-++@E
D&BA$9"~~|:{yy054t2+r)pnnlljjhhffddbb`|_]]rwZutWrUpohmPkNMbKIIGcbaCYBW@>Z=;;PUT6RK4I200..,,**(
(&&$@#>=<}:981xw4u21rpp-,+*#(ih%$d"!bw|_]]rwvXtmVkTRRPPNNLLJJHHFFDDBB@\?ZY<W:UTSRKP32M0KJ-HGF(
(=BA$9"!<;{98y0wu32r0)p'nlljjh&%e#zcxa__]][[YYWWUqTonQleNiLK`eHcbDDYB]@?TY<::O86R533HML.JC,A*(
(&&$@?>~6}49zxx/vttrrppnnllj(i&%$ezc~a`uz]xwYYtmrUpSnmOkdMbgJHH]FDDB^]\>T=RW:88M6442N1//DIH*F?
(=&$$""~~||zzx6w432s0).on+l)(igg$#zcb}`^^sxwYutWlqTRRglkMibK`IGGEECCAA??==;;99775Q422GL/JI,G*E
D=&%@#>=~||98705vut+0qoo&mk)jhh}$#c!xav_]yxwYoXmVTTRRPPNNLLJJHHFbE`_B]@[ZYRW:U8S6QP22MLKJC,G*)
>'<%##!!}}{{yywwuussqqo-nll#(i&%$e"!~}v_^]r[pYWsVTTinmOkdMbKIedFb[DYB@@>><<::8866442N1LK.IB+*E
(CB%##8=~}:{yy054t21r)pnnl*kii~%$d"ybw`^zy[wpYnWUUSSQQOOMMKKIeHcbE`CX]@?>SX;VU866QJ321/KJ,HA*?
(&&$$""~~||zzxxvvt2s0/p-n+$k(ih}$e"!aa|{ty\wZYWWUUSSQmlNjcLafIGG\ECCA]\>ZS<QV977L53311//-I,GFE
(CB;@#"=~;:{yy654-tsr)p',+k)"i~geecca}|^zs\qvYWWlUSSQQOOMMKKIIGcFa`C^A\[ZS<W:9NS6QP22MLKJCH+F)
(&&$$""~~||z876v.u,1rpp'nlljjhhf$e"!~a|{zyrwZYtWrqTonmOOdihK`IHcbD`_BW@>><X;99NSR4PI2G0..,H+))
>CB$@9"7~||zzxxvvttr0q.-n+$kj'h%$eccxa`_ty\ZZoXVVTponPfOdMKKIedcE[DY^A??T=;;997755331M0KJ-H+@)
(C&A@#!!<5:{zy0wu32r0)p',mkk"iggeeccaa__]][[YYWsVqpSnQlejMhKfIdcEE`_XA\?ZY;WV9N75Q422GLK-IB+@)
''%%##!=<|:3z16wuu,sqqoommkki'hff{"c~}|_zyr[ZuXsrUSSnmlejMLgJHH]baC_^AV?==;W:88MRQ3OH1F/--++))
''%%##!!};|zz16w43t1r/.-&+l)ji~g|#"!aw`uz][[pYWWUUSonPleNchKII^GEECCA]\>ZS<QV977L53311//-I,GFE
(CBA@9"!<}:9z765uu,10q(onm$k"ig%fddy~}_{t]r[YYWsVTTinmOkdMbKIedFb[DYB@@>><<::886R5PO2MF/J-,AFE
'CB%:#8=~;:9z16wv32r0/p'nllj(igg|#"b~w`u^\x[YYnsrTpiRgPNNLLJJHHFFDDB^A\[>Y<WP9T76KP3NM//JIBG*E
('<A$""7<;:z2y0wuussq/.-m%l#jh&%$dzcxa_{zy[qZoXVVTTRRPPNjMhgfIdc\aDC^]?[Z=R;99775Q422GLK-IB+@)
'CB$@9"7<}{{2ywwuussqqoom+l)(i&g$#"yb}`{^yxZZutsrkpSnQlOMMbgJHH]baC_XAV?=YXW9O8M64PON0F/DI,**?
(&&$$""~~||zzxxv4u210q.-,+$)ji&g$#d!~}__tyx[pYXWlUjonPleNchKII^GEECCA]@>>SXW9UN7L53ON0LE.C,**(
(&&$$""~<}:9z70wv3trr).-m+*k"igge#dbbw|{]yr[pYWWUqpRngPeNLLJJHHFFDDB^A\[>Y<Q:98M644220LK-IB+@)
'CBA#9"7~|:9y70w.3trr)pn,+k)"i~%fdd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%f#"!aav{z]r[ZuXVVkponPlOdihgI_H]FDDBB@\[Z<R;P977553311//--+G*E
D'B;$#>=};:{27xvv-21q/(o&mkki'&f${dyb``^^\\ZZXXVVTTRnQlkNiLaJIdGbaDBB]V[>=X;99NS644IN1LK.I,G@E
(C&A$""7<}{{27x543t10)po,m*)jhh%$#z!ba|_]]rwZXXmrUpoRmPkjibgJIdGEEZ_B@@UZ=XW:U8SRQPI2M0/D-B+)E
DC%;$9"~~||zzxxvvttrrppn,m*)(!hg$e"!b``uz]\wZXXmrUSShmPkjMhK`eHGbECCX]@>>SX;VU8S6QJ32M0KJ-++FE
>C&%@#!!6;|zz16w43t1r/.',ml)jhh}$eccx}`{z]x[vutmVUpSnmPNNihgf_dGFaDBBW\?==RW:UT7R5PONMFK.I,G*E
DCBA##8=<}4{8y65u32s*qoom+*j(!h}$eccxa__]][[YYWWUUSSQmPNNchKfed]FE`CAAV[><<QV9TS6Q4I21L/JI,**E
>C&%@#!!6;|zz16w43t1r/(-nm*kii~%fddy~a|{^y\wvoXWrUpoRPPkjibgJIdGEEZ_B@@UZ=XW:U8SRQJO2M0K.,,A*(
(&B%##8=<|:3z1xvvttrrppnnlljjh&g$#"c~}|{t]x[vYtsrqpRRglkNcLgJI^G\EC_B@@UZY;WP9N75Q422GLK-IB+@)
'CB$@9"7~||zzxxvvttrrp.o,+*#j'h%f#"bbw|_z]\qvuWslUjoRPPeNLhgfH^G\ECCAA??==;;9977553O2MLK.CH+*)
>C&A@#>!<5|{8y65vtt10).on+ljj!&geez!b}|_z]xwpuXsVUjonPleNchKII^GEEC_B@@UZYX:P9N7553ON0LE.CH+))
>'%%##!!}}{{y7x543t10/(on+l)(igg$#"!x}`_z][[puXVVkpSnmPkNihgf_dGbE`C^]\[Z<<QVU8M6Q43H1FKJ,HA*?
D'%%:#!!};|zz165u3,s*qo-,l*#j!hffddbb``^^\\ZvYtsrkToRQfkNLLafedF\EZCA]@>>SXW9UN7L53311//--++))
''%%#?"=<;|3zy6w43trr/(-nm*kii~%fddy~a|{^y\wpuXsVUjSQmlNjcLafIGG\ECCA]\[=S<QV977L53311//--++))
'C&A@?"=<5|9z7x54tt10/(-n+l)jhh}$#"bxav_]][[YYWWUUSSQQOOMMKgJedcFa`_X]@?Z=;;PU866KP3NM0K.IHGF?
(C&%:#8=~||387w5.u,sqqo-,l*#j!hffddbb``^^\\ZZXtWrqpiRQlOjiLJJ_dGFaDBBW\?==RW:UT7R5JO2M0K.,,A*?
DC%A:#8=~||3zxxvvttr0/o-&m$)jhh}fddbb``^^\\ZvYtsrUpiRQPejMhgJHHcb[`CB]\[=S<Q:8866442NML.D-B+))
''%%##!!};|98y6w43,1r/po&+*)i!h}fd"!~`v_t][wvXtmVkTRnmOkdMbKIedFb[DY^A??T=;;997755331M0KJI,GFE
>'&%:?"=<}{{8765.3ts0/o-&m$kiiggeec!~}_u^s\ZZXXVVTTRRPlOjiLgJedcb[`C^A\?ZYXWV88MRQ4I2M0/D-B+))
'CB$@9"7<}{{2yw54t2+r)pnnlljjhhffddb~a|{zs\[vYWWlqTRRglOjiLgJ_HGbE`_B@@[TY<;V977LQ422GL/JI,G*E
>C&%@#!!6;|zz16w43t1r/.'nm*k('hff#"!x}`_z][[puXVVkpSnmPkNihg`eHGbECCX]@>>SX;VU8S6QPONG0K.-BG*(
(=&;@#!!6;:9y1x/vttrrp.-m+$k"iggeeccaa__]][wZutslUToRmlOMMbgJIdGEEZ_B@@UZ=XW:U8MR54O200EJ-++@E
(CB%@#>7~;|9z76vv32+0q.on%l#jh&geez!~`|u^s\ZZXtsUqjShmPNNcLJfeGc\EZ_B@@U><<::8866442N1LKJ-HG@E
('B%##8=~||38y65v3t10/(on+l)(igg$#"!x}`_z][[puXVVkpSnmPkNihgf_dGbEDYBW\?==RWV8TM6K42NML.D-B+))
''%%##!!}}{{yyw5v321*qp-nll#(igg|ez!b}|_zs\[ZoXmVTponPfOdiLJJ_HFFD`CAAV[Z<XQ:O866442200..,,*F)
DC&A$9"!<}:9zxx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K.I,+SR
DP&AM?K~<H{F8x6Bu3?r0/.-9+kj5h3f$#"!~`<{]\8Z6uW3r~po{mlx*iu'feqpo!`lB]i?ZfXWc9T`65P\[1YX.V,GS)
('BN$?KJ}H:9Ex6B43?>0<o-9l*j5'g%ed".~=<^zy87YXtVr~}|nmykw)htsr$co!`CkA\[>=XdcUa`_^PO21Y/W-,+SR
(P&AM#>~<H{9EDwv4@21q<.:9+kj54&%ed".>=_^z9[w6X4s21p/nzykjvhgs%$ponDlB]i?ZYeWVU87R54\NM0XJIUGF)
DCO%ML"=IHGFE7wvAt?rqp.:,+k654gf$T/RQ


Maple

There is a built-in command for this in Maple.

> StringTools:-Encode( "The Quick Brown Fox Jumped Over The Lazy Dog!", encoding = rot13 ); 
            "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt!"

Mathematica/Wolfram Language

Rot13[s_] := StringReplace[
  s,
  # -> RotateLeft[#, 13] & @* CharacterRange @@ # &[
    {"a", "z"}, {"A", "Z"}
  ] // Thread
]
Rot13["Hello World!"]
Rot13[%]
Output:
Uryyb Jbeyq!
Hello World!

MATLAB

function r=rot13(s)
    if ischar(s)
        r=s;  % preallocation and copy of non-letters
        for i=1:size(s,1)
            for j=1:size(s,2)
                if isletter(s(i,j))
                    if s(i,j)>=97   % lower case
                        base = 97;
                    else            % upper case
                        base = 65;
                    end
                    r(i,j)=char(mod(s(i,j)-base+13,26)+base);
                end
            end
        end
    else
        error('Argument must be a CHAR')
    end
end

Call it like this:

>> rot13('Hello World!')

ans =

Uryyb Jbeyq!

It is possible to vectorize this code, the example below is not fully vectorized in order to make the order of operations clear. It is possible to reduce this solution to two lines by integrating the "selectedLetters" calculations directly into the line following them.

function text = rot13(text)
    if ischar(text)
        
        selectedLetters = ( (text >= 'A') & (text <= 'Z') ); %Select upper case letters
        text(selectedLetters) = char( mod( text(selectedLetters)-'A'+13,26 )+'A' );
        
        selectedLetters = ( (text >= 'a') & (text <= 'z') ); %Select lower case letters
        text(selectedLetters) = char( mod( text(selectedLetters)-'a'+13,26 )+'a' );

    else
        error('Argument must be a string.')
    end
end

Sample Output:

>> plainText = char((64:123))

plainText =

@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{

>> rot13(plainText)

ans =

@NOPQRSTUVWXYZABCDEFGHIJKLM[\]^_`nopqrstuvwxyzabcdefghijklm{

Maxima

rot13(a) := simplode(map(ascii, map(lambda([n],
      if (n >= 65 and n <= 77) or (n >= 97 and n <= 109) then n + 13
      elseif (n >= 78 and n <= 90) or (n >= 110 and n <= 122) then n - 13
      else n), map(cint, sexplode(a)))))$

lowercase: "abcdefghijklmnopqrstuvwxyz"$
uppercase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"$

rot13(lowercase);
"nopqrstuvwxyzabcdefghijklm"

rot13(uppercase);
"NOPQRSTUVWXYZABCDEFGHIJKLM"

rot13("The quick brown fox jumps over the lazy dog");
"Gur dhvpx oebja sbk whzcf bire gur ynml qbt"

rot13(%);
"The quick brown fox jumps over the lazy dog"

Mercury

:- module rot13.

:- interface.

:- import_module io.
:- pred main(io::di, io::uo) is det.

:- implementation.

:- import_module string, set, list, char, int.
:- type transition == {character, character}.
:- type transitions == set(transition).
:- type rot_kind
    --->    encrypt
    ;       decrypt.

:- pred build_transition(int::in, rot_kind::in, int::in, int::in, character::in,
    transitions::in, transitions::out) is det.
build_transition(Offset, Kd, Lb, Ub, Ch, St, Rs) :-
    (
        Kd = encrypt,
        Diff = to_int(Ch) + Offset
    ;
        Kd = decrypt,
        Diff = to_int(Ch) - Offset
    ),
    (if (Diff >= (Ub + 0x01))
        then Ct = {Ch, det_from_int(Lb + (Diff - Ub) - 0x01) `with_type` char}
    else if (Diff =< (Lb - 0x01))
        then Ct = {Ch, det_from_int(Ub - (Lb - Diff) + 0x01) `with_type` char}
        else Ct = {Ch, det_from_int(Diff) `with_type` char}),
    union(St, make_singleton_set(Ct), Rs).

:- pred generate_alpha_transition(int::in, rot_kind::in, transitions::out) is det.
generate_alpha_transition(N, Kd, Ts) :-
    Offset = N mod 0x1A,
    to_char_list("abcdefghijklmnopqrstuvwxyz", Lower),
    to_char_list("ABCDEFGHIJKLMNOPQRSTUVWXYZ", Upper),
    foldl(build_transition(Offset, Kd, 0x61, 0x7A), Lower, init, Ts0),
    foldl(build_transition(Offset, Kd, 0x41, 0x5A), Upper, Ts0, Ts).

:- pred rot(transitions::in, string::in, string::out) is det.
rot(Ts, Base, Result) :-
    to_char_list(Base, Fragment),
    map((pred(Ch::in, Rs::out) is det :-
        promise_equivalent_solutions [Rs]
            (if member({Ch, Nx}, Ts)
                then Rs = Nx
                else Rs = Ch)
    ), Fragment, Result0),
    from_char_list(Result0, Result).

:- pred invoke_line(transitions::in, string::in, text_input_stream::in, io::di, io::uo) is det.
invoke_line(Ts, File, Stream, !IO) :-
    read_line_as_string(Stream, Line, !IO),
    (
        Line = ok(Base),
        rot(Ts, Base, Rot),
        write_string(Rot, !IO),
        invoke_line(Ts, File, Stream, !IO)
    ;
        Line = error(_),
        format("Can't read correctly the file %s.\n", [s(File)], !IO)
    ;
        Line = eof
    ).

:- pred handle_files(transitions::in, list(string)::in, io::di, io::uo) is det.
handle_files(_, [], !IO).
handle_files(Ts, [Head|Tail], !IO) :-
    open_input(Head, Result, !IO),
    (
        Result = ok(Stream),
        invoke_line(Ts, Head, Stream, !IO),
        close_input(Stream, !IO)
    ;
        Result = error(_),
        format("Can't open the file %s.\n", [s(Head)], !IO)
    ),
    handle_files(Ts, Tail, !IO).

main(!IO) :-
    generate_alpha_transition(0x0D, encrypt, Table),
    command_line_arguments(Args, !IO),
    (
        Args = [_|_],
        handle_files(Table, Args, !IO)
    ;
        Args = [],
        invoke_line(Table, "<stdin>", stdin_stream, !IO)
    ).

:- end_module rot13.

MiniScript

rot13 = function(s)
    chars = s.values
    for i in chars.indexes
        c = chars[i]
        if c >= "a" and c <= "z" then chars[i] = char(97 + (code(c)-97+13)%26)
        if c >= "A" and c <= "Z" then chars[i] = char(65 + (code(c)-65+13)%26)
    end for
    return chars.join("")
end function

print rot13("Hello world!")
print rot13("Uryyb jbeyq!")
Output:
Uryyb jbeyq!
Hello world!

Mirah

def rot13 (value:string)
    result = ""
    d = ' '.toCharArray[0]
    value.toCharArray.each do |c|
        testChar = Character.toLowerCase(c)
        if testChar <= 'm'.toCharArray[0] && testChar >= 'a'.toCharArray[0] then 
            d = char(c + 13)
        end
        if testChar <= 'z'.toCharArray[0] && testChar >= 'n'.toCharArray[0] then 
            d = char(c - 13) 
        end 
        result += d
    end 
    result
end


puts rot13("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

ML

Standard ML

fun rot13char c =
  if c >= #"a" andalso c <= #"m" orelse c >= #"A" andalso c <= #"M" then
    chr (ord c + 13)
  else if c >= #"n" andalso c <= #"z" orelse c >= #"N" andalso c <= #"Z" then
    chr (ord c - 13)
  else
    c

val rot13 = String.map rot13char

mLite

Reads text file from stdin to list of lines, encodes and prints lines of encoding to stdout.

fun readfile () = readfile []
           | x = let val ln = readln ()
                 in if eof ln then
                      rev x
                    else
                      readfile ` ln :: x
                 end

local
	val lower_z = ord #"z";
	val upper_z = ord #"Z";
	val lower_a = ord #"a";
	val upper_a = ord #"A";
	
	fun which 
			(c_upper c) = (upper_a, upper_z)
		|	_	    = (lower_a, lower_z)
		;
	
	fun scale 
			(c, az) where (c > #1 az) = scale( (#0 az + (c - #1 az - 1)), az)
		|	(c, az) 		  = c
			
in
	fun rot13
			([], t) 			    = implode ` rev t
		|	(x :: xs, t) where (c_alphabetic x) = rot13 (xs, (chr ` scale (ord x + 13, which x)) :: t)
		|	(x :: xs, t)                        = rot13 (xs, x :: t)
		|	s 				    = rot13 (explode s, [])
end;

map (println o rot13) ` readfile ();

MMIX

// main registers
p	IS	$255	% text pointer
c	GREG		% char
cc	GREG		% uppercase copy of c
u	GREG		% all purpose

	LOC	Data_Segment
	GREG	@
Test	BYTE	"dit is een bericht voor de keizer",#a,0

	LOC	#100
Main	LDA	p,Test
	TRAP	0,Fputs,StdOut	% show text to encrypt
	LDA	p,Test		% points to text to encrypt
	JMP	4F
// do in place text encryption
				% REPEAT
2H	ADD	cc,c,0		%  copy char
	SUB	cc,cc,' '	%  make uppercase
	CMP	u,cc,'A'
	BN	u,3F		%  IF c < 'A' OR c > 'Z' THEN next char
	CMP	u,cc,'Z'
	BP	u,3F
	CMP	u,cc,'N'	%  ELSE
	BN	u,1F		%    IF c < 'N' THEN encrypt 'up'
	SUB	c,c,26		%    ELSE char ready for encrypt 'down'
1H	INCL	c,13		%  encrypt char
	STBU	c,p		%  replace char with encrypted char
3H	INCL	p,1		%  move to next char
4H	LDBU	c,p		%  get next char
	PBNZ	c,2B		% UNTIL EOT
// print result
	LDA	p,Test
	TRAP	0,Fputs,StdOut	% show encrypted text
	TRAP	0,Halt,0

Example:

~/MIX/MMIX/Progs> mmix rot13simpl
dit is een bericht voor de keizer
qvg vf rra orevpug ibbe qr xrvmre


Modula-2

MODULE Rot13;

FROM STextIO IMPORT
    ReadString, WriteString, WriteLn;
FROM Strings IMPORT
    Length;

TYPE
    MyString = ARRAY [0..80] OF CHAR;

VAR
    S, T : MyString;

PROCEDURE Rot13(S : ARRAY OF CHAR; VAR T : ARRAY OF CHAR);
VAR
    I, J : CARDINAL;
BEGIN
    FOR I := 0 TO Length(S) - 1
        DO
            J := ORD(S[I]);
            IF ((J >= 65) AND (J <= 90)) THEN
                J := (J - 52) % 26 + 65;
            IF ((J >= 97) AND (J <= 122)) THEN
                J := (J - 84) % 26 + 97;
            T[I] := CHR(J);
        END;
END Rot13;

BEGIN
    WHILE NOT Eof
        DO
            ReadString(S);
            SkipLine;
            WriteLn;
            Rot13(S, T);
            WriteString(T);
            WriteLn;
        END;
END Rot13.


Modula-3

This implementation reads from stdin and writes to stdout.

MODULE Rot13 EXPORTS Main;

IMPORT Stdio, Rd, Wr;

VAR c: CHAR;

<*FATAL ANY*>

BEGIN
  WHILE NOT Rd.EOF(Stdio.stdin) DO
    c := Rd.GetChar(Stdio.stdin);
    IF c >= 'A' AND c <= 'M' OR c >= 'a' AND c <= 'm' THEN
      c := VAL(ORD((ORD(c) + 13)), CHAR);
    ELSIF c >= 'N' AND c <= 'Z' OR c >= 'n' AND c <= 'z' THEN
      c := VAL(ORD((ORD(c) - 13)), CHAR);
    END;
    Wr.PutChar(Stdio.stdout, c);
  END;
END Rot13.

Output:

martin@thinkpad:~$ ./prog
Foo bar baz
Sbb one onm
martin@thinkpad:~$ echo "Bar baz foo" | ./prog
One onm sbb
martin@thinkpad:~$ echo "Foo bar baz" > foo.txt 
martin@thinkpad:~$ echo "quux zeepf" >> foo.txt 
martin@thinkpad:~$ cat foo.txt | ./prog
Sbb one onm
dhhk mrrcs

MUMPS

Rot13(in)	New low,rot,up
	Set up="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Set low="abcdefghijklmnopqrstuvwxyz"
	Set rot=$Extract(up,14,26)_$Extract(up,1,13)
	Set rot=rot_$Extract(low,14,26)_$Extract(low,1,13)
	Quit $Translate(in,up_low,rot)

Write $$Rot13("Hello World!") ; Uryyb Jbeyq!
Write $$Rot13("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ; NOPQRSTUVWXYZABCDEFGHIJKLM

Nanoquery

def rot13(plaintext)
	uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	lowercase = "abcdefghijklmnopqrstuvwxyz"

	cypher = ""
	for char in plaintext
		if uppercase .contains. char
			cypher += uppercase[uppercase[char] - 13]
		else if lowercase .contains. char
			cypher += lowercase[lowercase[char] - 13]
		else
			cypher += char
		end
	end

	return cypher
end
Output:
% import "rot13.nq"
% println rot13("This is a test.")
Guvf vf n grfg.
% println rot13("Nanoquery 2.3")
Anabdhrel 2.3

Neko

rotate13 function based on ALGOL-68 entry.

/*
 ROT-13 in Neko
*/

/* Assume ASCII encoding */
var rotate13 = function(c) {
    if (c >= 65 && c <= 77) || (c >= 97 && c <= 109)
        c += 13
    else
        if (c >= 78 && c <= 90) || (c >= 110 && c <= 122)
            c -= 13
    return c
}

var rot13 = function(s) {
    var r = $scopy(s)
    var len = $ssize(r)
    var pos = 0
    while pos < len {
        $sset(r, pos, rotate13($sget(r, pos)))
        pos += 1
    }
    return r
}

var msg = $loader.args[0]
if msg == null {
    var testing = "[abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ]"
    $print(testing, "\n", replaced = rot13(testing), "\n")
    $print(rot13(replaced), "\n")
    $print("\n")
    msg = "The secret message said \"Open Sesame!\""
}
$print(msg, "\n", replaced = rot13(msg), "\n")
$print(rot13(replaced), "\n")
Output:
prompt$ nekoc rot-13.neko
prompt$ neko rot-13
[abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ]
[nopqrstuvwxyzabcdefghijklm 0123456789 NOPQRSTUVWXYZABCDEFGHIJKLM]
[abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ]

The secret message said "Open Sesame!"
Gur frperg zrffntr fnvq "Bcra Frfnzr!"
The secret message said "Open Sesame!"

prompt$ neko rot-13 'nowhere ABJURER'
nowhere ABJURER
abjurer NOWHERE
nowhere ABJURER

NetRexx

This sample leverages the code demonstrated in the Caesar cipher – NetRexx task.

/* NetRexx */
options replace format comments java crossref savelog symbols nobinary

parse arg fileNames

rdr = BufferedReader

do
  if fileNames.length > 0 then do
    loop n_ = 1 for fileNames.words
      fileName = fileNames.word(n_)
      rdr = BufferedReader(FileReader(File(fileName)))
      encipher(rdr)
      end n_
    end
  else do
    rdr = BufferedReader(InputStreamReader(System.in))
    encipher(rdr)
    end
catch ex = IOException
  ex.printStackTrace
end

return

method encipher(rdr = BufferedReader) public static signals IOException

  loop label l_ forever
    line = rdr.readLine
    if line = null then leave l_
    say rot13(line)
    end l_
  return

method rot13(input) public static signals IllegalArgumentException

  return caesar(input, 13, isFalse)

method caesar(input = Rexx, idx = int, caps = boolean) public static signals IllegalArgumentException

  if idx < 1 | idx > 25 then signal IllegalArgumentException()

  --      12345678901234567890123456
  itab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  shift = itab.length - idx
  parse itab tl +(shift) tr
  otab = tr || tl

  if caps then input = input.upper

  cipher = input.translate(itab || itab.lower, otab || otab.lower)

  return cipher

method caesar_encipher(input = Rexx, idx = int, caps = boolean) public static signals IllegalArgumentException

  return caesar(input, idx, caps)

method caesar_decipher(input = Rexx, idx = int, caps = boolean) public static signals IllegalArgumentException

  return caesar(input, int(26) - idx, isFalse)

method caesar_encipher(input = Rexx, idx = int) public static signals IllegalArgumentException

  return caesar(input, idx, isFalse)

method caesar_decipher(input = Rexx, idx = int) public static signals IllegalArgumentException

  return caesar(input, int(26) - idx, isFalse)

method caesar_encipher(input = Rexx, idx = int, opt = Rexx) public static signals IllegalArgumentException

  return caesar(input, idx, opt)

method caesar_decipher(input = Rexx, idx = int, opt = Rexx) public static signals IllegalArgumentException

  return caesar(input, int(26) - idx, opt)

method caesar(input = Rexx, idx = int, opt = Rexx) public static signals IllegalArgumentException

  if opt.upper.abbrev('U') >= 1 then caps = isTrue
  else                               caps = isFalse

  return caesar(input, idx, caps)

method caesar(input = Rexx, idx = int) public static signals IllegalArgumentException

  return caesar(input, idx, isFalse)

method isTrue public static returns boolean
  return (1 == 1)

method isFalse public static returns boolean
  return \isTrue

Output (using the source file as input):

/* ArgErkk */
bcgvbaf ercynpr sbezng pbzzragf wnin pebffers fnirybt flzobyf abovanel

cnefr net svyrAnzrf

eqe = OhssrerqErnqre

qb
  vs svyrAnzrf.yratgu > 0 gura qb
    ybbc a_ = 1 sbe svyrAnzrf.jbeqf
      svyrAnzr = svyrAnzrf.jbeq(a_)
      eqe = OhssrerqErnqre(SvyrErnqre(Svyr(svyrAnzr)))
      rapvcure(eqe)
      raq a_
    raq
  ryfr qb
    eqe = OhssrerqErnqre(VachgFgernzErnqre(Flfgrz.va))
    rapvcure(eqe)
    raq
pngpu rk = VBRkprcgvba
  rk.cevagFgnpxGenpr
raq

erghea

zrgubq rapvcure(eqe = OhssrerqErnqre) choyvp fgngvp fvtanyf VBRkprcgvba

  ybbc ynory y_ sberire
    yvar = eqe.ernqYvar
    vs yvar = ahyy gura yrnir y_
    fnl ebg13(yvar)
    raq y_
  erghea

zrgubq ebg13(vachg) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, 13, vfSnyfr)

zrgubq pnrfne(vachg = Erkk, vqk = vag, pncf = obbyrna) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  vs vqk < 1 | vqk > 25 gura fvtany VyyrtnyNethzragRkprcgvba()

  --      12345678901234567890123456
  vgno = 'NOPQRSTUVWXYZABCDEFGHIJKLM'
  fuvsg = vgno.yratgu - vqk
  cnefr vgno gy +(fuvsg) ge
  bgno = ge || gy

  vs pncf gura vachg = vachg.hccre

  pvcure = vachg.genafyngr(vgno || vgno.ybjre, bgno || bgno.ybjre)

  erghea pvcure

zrgubq pnrfne_rapvcure(vachg = Erkk, vqk = vag, pncf = obbyrna) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, vqk, pncf)

zrgubq pnrfne_qrpvcure(vachg = Erkk, vqk = vag, pncf = obbyrna) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, vag(26) - vqk, vfSnyfr)

zrgubq pnrfne_rapvcure(vachg = Erkk, vqk = vag) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, vqk, vfSnyfr)

zrgubq pnrfne_qrpvcure(vachg = Erkk, vqk = vag) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, vag(26) - vqk, vfSnyfr)

zrgubq pnrfne_rapvcure(vachg = Erkk, vqk = vag, bcg = Erkk) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, vqk, bcg)

zrgubq pnrfne_qrpvcure(vachg = Erkk, vqk = vag, bcg = Erkk) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, vag(26) - vqk, bcg)

zrgubq pnrfne(vachg = Erkk, vqk = vag, bcg = Erkk) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  vs bcg.hccre.nooeri('H') >= 1 gura pncf = vfGehr
  ryfr                               pncf = vfSnyfr

  erghea pnrfne(vachg, vqk, pncf)

zrgubq pnrfne(vachg = Erkk, vqk = vag) choyvp fgngvp fvtanyf VyyrtnyNethzragRkprcgvba

  erghea pnrfne(vachg, vqk, vfSnyfr)

zrgubq vfGehr choyvp fgngvp ergheaf obbyrna
  erghea (1 == 1)

zrgubq vfSnyfr choyvp fgngvp ergheaf obbyrna
  erghea \vfGehr

NewLISP

(define (rot13 str)
  (join
   (map
    (fn(c) 
      (cond
       ((<= "A" (upper-case c) "M") (char (+ (char c) 13)))
       ((<= "N" (upper-case c) "Z") (char (- (char c) 13)))
       (true c)))
    (explode str))))

Nim

import strutils

proc rot13(c: char): char =
  case toLowerAscii(c)
  of 'a'..'m': chr(ord(c) + 13)
  of 'n'..'z': chr(ord(c) - 13)
  else:        c

for line in stdin.lines:
  for c in line:
    stdout.write rot13(c)
  stdout.write "\n"

Objeck

bundle Default {
  class Rot13 {
    function : Main(args : String[]) ~ Nil {
      Rot13("nowhere ABJURER")->PrintLine();
    }

    function : native : Rot13(text : String) ~ String {
      rot := "";
      each(i : text) {
        c := text->Get(i);
        if(c >= 'a' & c <= 'm' | c >= 'A' & c <= 'M') {
          rot->Append(c + 13);
        }
        else if(c >= 'n' & c <= 'z' | c >= 'N' & c <= 'Z') {
          rot->Append(c - 13);
        }
        else {
          rot->Append(c);
        };
      };

      return rot;
    }
  }
}

OCaml

Straightforward implementation for characters by using character range patterns:

let rot13 c = match c with
  | 'A'..'M' | 'a'..'m' -> char_of_int (int_of_char c + 13)
  | 'N'..'Z' | 'n'..'z' -> char_of_int (int_of_char c - 13)
  | _ -> c

We provide a function for converting whole strings:

let rot13_str s =
  let len = String.length s in
  let result = String.create len in
  for i = 0 to len - 1 do
    result.[i] <- rot13 s.[i]
  done;
  result

(* or in OCaml 4.00+:
   let rot13_str = String.map rot13
*)

And here is a utility program that converts the content read on sdtin and write it to stdout:

let () =
  try while true do
    String.iter (fun c -> print_char (rot13 c)) (read_line());
    print_newline()
  done with End_of_file -> ()

Oforth

: encryptRot13(c)
   c dup isLetter ifFalse: [ return ]
   isUpper ifTrue: [ 'A' ] else: [ 'a' ] c 13 + over - 26 mod + ;

: rot13   map(#encryptRot13) charsAsString ;
Output:
>"Oolite quick Thargoid jumps lazy Vipers = blown up + special fx" rot13 println
Bbyvgr dhvpx Gunetbvq whzcf ynml Ivcref = oybja hc + fcrpvny sk

Ol

(import (scheme char))

(define (rot13 str)
   (runes->string (map (lambda (ch)
         (+ ch (cond
                  ((char-ci<=? #\a ch #\m)
                     13)
                  ((char-ci<=? #\n ch #\z)
                     -13)
                  (else 0))))
      (string->runes str))))

(define str "`What a curious feeling!' said Alice; `I must be shutting up like a telescope.'")
(print (rot13 str))
(print (rot13 (rot13 str)))
Output:
`Jung n phevbhf srryvat!' fnvq Nyvpr; `V zhfg or fuhggvat hc yvxr n gryrfpbcr.'
`What a curious feeling!' said Alice; `I must be shutting up like a telescope.'

Oz

declare
  fun {RotChar C}
     if     C >= &A andthen C =< &Z then &A + (C - &A + 13) mod 26
     elseif C >= &a andthen C =< &z then &a + (C - &a + 13) mod 26
     else C
     end
  end

  fun {Rot13 S}
     {Map S RotChar}
  end
in
  {System.showInfo {Rot13 "NOWHERE Abjurer 42"}}
  {System.showInfo {Rot13 {Rot13 "NOWHERE Abjurer 42"}}}

PARI/GP

rot13(s)={
  s=Vecsmall(s);
  for(i=1,#s,
    if(s[i]>109&s[i]<123,s[i]-=13,if(s[i]<110&s[i]>96,s[i]+=13,if(s[i]>77&s[i]<91,s[i]-=13,if(s[i]<78&s[i]>64,s[i]+=13))))
  );
  Strchr(s)
};

Pascal

program rot13;

var
    line: string;

    function rot13(someText: string): string;

    var
        i: integer;
        ch: char;
        result: string;

    begin
        result := '';
        for i := 1 to Length(someText) do
            begin
                ch := someText[i];
                case ch of
                    'A' .. 'M', 'a' .. 'm':
                        ch := chr(ord(ch)+13);
                    'N' .. 'Z', 'n' .. 'z':
                        ch := chr(ord(ch)-13);
                end;
                result := result + ch;
            end;
        rot13 := result;
    end;

begin
    while not eof(input) do
        begin
            readln(line);
            writeln(rot13(line));
        end;
end.

Perl

sub rot13 {
  shift =~ tr/A-Za-z/N-ZA-Mn-za-m/r;
}
 
print rot13($_) while (<>);

Input:

NOWHERE Abjurer

Output:

ABJURER Nowhere

One-liner version:

perl -pe 'tr/A-Za-z/N-ZA-Mn-za-m/'

Phix

function rot13(string s)
integer ch
    for i=1 to length(s) do
        ch = upper(s[i])
        if ch>='A' and ch<='Z' then
            s[i] += iff(ch<='M',+13,-13)
        end if
    end for
    return s
end function
?rot13("abjurer NOWHERE.")
Output:
"nowhere ABJURER."

PHP

PHP has a built-in function for this:

echo str_rot13('foo'), "\n";

will output

sbb

Here is an implementation:

<?php
function rot13($s) {
    return strtr($s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
                     'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm');
}

echo rot13('foo'), "\n";
?>

Output:

sbb

Picat

go =>
  S = "Big fjords vex quick waltz nymph!",
  println(S),
  println(rot13(S)),
  println(rot13(rot13(S))),
  nl.
    
% Rot 13 using a map
rot13(S) = S2 =>
  lower(Lower),
  upper(Upper),
  M = create_map(Lower, Upper),
  % If a char is not in a..zA..z then show it as it is.
  S2 := [M.get(C,C) : C in S].

create_map(Lower, Upper) = M =>
  M = new_map(),
  Len = Lower.length,
  LDiv := Lower.length div 2,
  foreach(I in 1..Len)
    II = (LDiv+I) mod Len,
    if II == 0 then II := Len end,
    M.put(Upper[I],Upper[II]),
    M.put(Lower[I],Lower[II])
  end.

lower("abcdefghijklmnopqrstuvwxyz").
upper("ABCDEFGHIJKLMNOPQRSTUVWXYZ").
Output:
Big fjords vex quick waltz nymph!
Ovt swbeqf irk dhvpx jnygm alzcu!
Big fjords vex quick waltz nymph!

PicoLisp

(de rot13-Ch (C)
   (if
      (or
         (member C '`(apply circ (chop "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) 
         (member C '`(apply circ (chop "abcdefghijklmnopqrstuvwxyz"))) )
      (get @ 14)
      C ) )

or:

(de rot13-Ch (C)
   (cond
      ((>= "M" (uppc C) "A")
         (char (+ (char C) 13)) ) 
      ((>= "Z" (uppc C) "N")
         (char (- (char C) 13)) ) 
      (T C) ) )

Then call it as:

(de rot13-stdIn ()
   (while (line)
      (prinl (mapcar rot13-Ch @)) ) )

Pike

import Crypto;

int main(){
   string r = rot13("Hello, World");
   write(r + "\n");
}

PL/I

rotate: procedure (in) options (main);    /* 2 March 2011 */
   declare in character (100) varying;
   declare line character (500) varying;
   declare input file;

   open file (input) title ('/' || in || ',type(text),recsize(500)' );

   on endfile (input) stop;

   do forever;
      get file (input) edit (line) (L);
      line = translate (
             line, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
                   'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm');
      put edit (line) (a); put skip;
   end;
end;

Data file:

"The time has come,"
the walrus said,
"to speak of many things;
of ships and shoes and sealing wax;
of cabbages and kings."

Output:

"Gur gvzr unf pbzr,"
gur jnyehf fnvq,
"gb fcrnx bs znal guvatf;
bs fuvcf naq fubrf naq frnyvat jnk;
bs pnoontrf naq xvatf."

PL/I-80

Since Subset G includes the translate() function, a PL/I-80 implementation could simply replicate the code given for the full language (and, for an unruly character set, would be the preferred way to go). But here is another approach that is fine for ASCII.

rot13_test:
  procedure options(main);

    %replace 
      true by '1'b,
      false by '0'b;

    dcl (plain, encoded) char(127) varying;

    plain = 'The quick brown fox jumps over the lazy red dog.';
    put skip list ('Plain text:', plain);
    encoded = rot13(plain);  
    put skip list ('Encoded   :', encoded);
    put skip list ('Restored  :', rot13(encoded));

    stop;

rot13:
    procedure (s) returns (char(127) varying);
      dcl
        s char(127) varying,
        ch char(1),
        i fixed bin(15);
      do i = 1 to length(s);
        ch = substr(s,i,1);
        if (isalpha(ch)) then
          do;
            if (toupper(ch) > 'M') then
              ch = ascii(rank(ch) - 13);
            else
              ch = ascii(rank(ch) + 13);
          end;
        substr(s,i,1) = ch;
      end;
      return (s);
    end rot13;

toupper:
    procedure (ch) returns (char(1));
      dcl ch char(1);
      dcl cout char(1);
      if ((ch >= 'a') & (ch <= 'z')) then
        cout = ascii(rank(ch) - 32);
      else
        cout = ch;
      return (cout);
    end toupper;

isalpha:
    procedure (ch) returns (bit(1));
      dcl ch char(1);
      if (((ch >= 'A') & (ch <= 'Z')) | 
          ((ch >= 'a') & (ch <= 'z'))) then
        return (true);
      else
        return (false);
    end isalpha;


end rot13_test;
Output:
Plain text: The quick brown fox jumps over the lazy red dog.
Encoded   : Gur dhvpx oebja sbk whzxc bire gur ynml erq qbt.
Restored  : The quick brown fox jumps over the lazy red dog.

PL/SQL

-- Works for VARCHAR2 (up to 32k chars)
CREATE OR REPLACE FUNCTION fn_rot13_native(p_text VARCHAR2) RETURN VARCHAR2 IS
  c_source CONSTANT VARCHAR2(52) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  c_target CONSTANT VARCHAR2(52) := 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
BEGIN
  RETURN TRANSLATE(p_text, c_source, c_target);
END;
/

-- For CLOBs (translate only works with VARCHAR2, so do it in chunks)
CREATE OR REPLACE FUNCTION fn_rot13_clob(p_text CLOB) RETURN CLOB IS
  c_source CONSTANT VARCHAR2(52) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  c_target CONSTANT VARCHAR2(52) := 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
  c_chunk_size CONSTANT PLS_INTEGER := 4000;
  v_result CLOB := NULL;
BEGIN
  FOR i IN 0..TRUNC(LENGTH(p_text) / c_chunk_size) LOOP
    v_result := v_result || 
      TRANSLATE(dbms_lob.substr(p_text, c_chunk_size, i * c_chunk_size + 1), c_source, c_target);
  END LOOP;
  RETURN v_result;
END;
/

-- The full algorithm (Slower. And MUCH slower if using CLOB!)
CREATE OR REPLACE FUNCTION fn_rot13_algorithm(p_text VARCHAR2) RETURN CLOB IS
  c_upper_a CONSTANT PLS_INTEGER := ASCII('A');
  c_lower_a CONSTANT PLS_INTEGER := ASCII('a');
  v_rot VARCHAR2(32000);
  v_char VARCHAR2(1);
BEGIN
  FOR i IN 1..LENGTH(p_text) LOOP
    v_char := SUBSTR(p_text, i, 1);
    IF v_char BETWEEN 'A' AND 'Z' THEN
      v_rot := v_rot || CHR(MOD(ASCII(v_char) - c_upper_a + 13, 26) + c_upper_a);
    ELSIF v_char BETWEEN 'a' AND 'z' THEN
      v_rot := v_rot || CHR(MOD(ASCII(v_char) - c_lower_a + 13, 26) + c_lower_a);
    ELSE
      v_rot := v_rot || v_char;
    END IF;
  END LOOP;
  RETURN v_rot;
END;
/
Output:
SELECT fn_rot13_native('Hello ROT-13') FROM DUAL;
SELECT fn_rot13_clob('Hello ROT-13') FROM DUAL;
SELECT fn_rot13_algorithm('Hello ROT-13') FROM DUAL;

-- All return:
-- Uryyb EBG-13

Pop11

In Pop11 characters are just integers, so we can use integer comparisons and arithmetic (assuming ASCII based encoding).

define rot13(s);
    lvars j, c;
    for j from 1 to length(s) do
        s(j) -> c;
        if `A` <= c and c <= `M` or `a` <= c and c <= `m` then
            c + 13 -> s(j);
        elseif `N` <= c and c <= `Z` or `n` <= c and c <= `z` then
            c - 13 -> s(j);
        endif;
    endfor;
    s;
enddefine;

rot13('NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm') =>

PostScript

Library: initlib
/r13 {
4 dict begin
    /rotc {
        {
        {{{64 gt} {91 lt}} all?} {65 - 13 + 26 mod 65 +} is?
        {{{95 gt} {123 lt}} all?} {97 - 13 + 26 mod 97 +} is?
        } cond
    }.
    {rotc} map cvstr
end}.

PowerBASIC

#COMPILE EXE
#COMPILER PBWIN 9.05
#DIM ALL

FUNCTION ROT13(BYVAL a AS STRING) AS STRING
  LOCAL p AS BYTE PTR
  LOCAL n AS BYTE, e AS BYTE
  LOCAL res AS STRING

  res = a
  p = STRPTR(res)
  n = @p
  DO WHILE n
    SELECT CASE n
      CASE 65 TO 90
        e = 90
        n += 13
      CASE 97 TO 122
        e = 122
        n += 13
      CASE ELSE
        e = 255
    END SELECT

    IF n > e THEN
      n -= 26
    END IF
    @p = n
    INCR p
    n = @p
  LOOP
FUNCTION = res
END FUNCTION

'testing:

FUNCTION PBMAIN () AS LONG
#DEBUG PRINT ROT13("abc")
#DEBUG PRINT ROT13("nop")
END FUNCTION

PowerShell

$e = "This is a test Guvf vf n grfg"

[char[]](0..64+78..90+65..77+91..96+110..122+97..109+123..255)[[char[]]$e] -join ""

A more POSH way..

function Invoke-Rot13 {
  param(
    [char[]]$message
  )
  begin {
    $outString = New-Object System.Collections.ArrayList
    $alpha = 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
    $alphaL = $alpha + $alpha
    $alphaU = $alphaL.toUpper()
    $int = 13
  }
  process{
    $message | ForEach-Object {
      # test if char is special
      if ($_ -match '[^\p{L}\p{Nd}]') {
        $outString += $_
      }
      # test if char is digit
      elseif ($_ -match '\d') {
        $outString += $_
      }
      # test if char is upperCase
      elseif ($_ -ceq $_.ToString().ToUpper()) {
        $charIndex = $alphaU.IndexOf($_.tostring())
        $outString += $alphaU[$charIndex+$int]
      }
      # test if char is lowerCase
      elseif ($_ -ceq $_.ToString().ToLower()) {
        $charIndex = $alphaL.IndexOf($_.tostring())
        $outString += $alphaL[$charIndex+$int]
      }
      else {
        $outString += $_
      }
    } # end foreach
  } # end process
  end {
    # output string and join all chars
    $outString -join ""
  }
} # end function

OutPut

PS> $message = '{!This is /A\ Test123}'
PS> $messageE = Invoke-Rot13 -message $message
PS> $messageE
PS> Invoke-Rot13 -message $messageE
{!Guvf vf /N\ Grfg123}
{!This is /A\ Test123}

Prolog

Works with Quintus Prolog.

:- use_module(library(ctypes)).

runtime_entry(start) :-
	prompt(_, ''),
	rot13.

rot13 :-
	get0(Ch),
	(   is_endfile(Ch) ->
		true
	;   rot13_char(Ch, Rot),
	    put(Rot),
	    rot13
	).

rot13_char(Ch, Rot) :-
	(   is_alpha(Ch) ->
		to_upper(Ch, Up),
		Letter is Up - 0'A,
		Rot is Ch + ((Letter + 13) mod 26) - Letter
	;   Rot = Ch
	).

Works with SWI-Prolog.

rot13(Str, SR) :-
	maplist(rot, Str, Str1),
	string_to_list(SR, Str1).

rot(C, C1) :-
	(   member(C, "abcdefghijklmABCDEFGHIJKLM") -> C1 is C+13;
	    (	member(C, "nopqrstuvwxyzNOPQRSTUVWXYZ") -> C1 is C-13; C1 = C)).

Output :

 ?- rot13("The Quick Brown Fox Jumped Over The Lazy Dog!", SR).
SR = "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt!".

PureBasic

Declare.s Rot13(text_to_code.s)

If OpenConsole()
  Define txt$
  
  Print("Enter a string to encode: "): txt$=Input()
 
  PrintN("Coded  : "+Rot13(txt$))
  PrintN("Decoded: "+Rot13(Rot13(txt$)))
 
  Print("Press ENTER to quit."): Input()
  CloseConsole()
EndIf

Procedure.s Rot13(s.s)
  Protected.i i
  Protected.s t, u
  For i=1 To Len(s)
    t=Mid(s,i,1)
    Select Asc(t)
      Case Asc("a") To Asc("m"), Asc("A") To Asc("M")
        t=chr(Asc(t)+13)
      Case Asc("n") To Asc("z"), Asc("N") To Asc("Z")
        t=chr(Asc(t)-13)
    EndSelect
    u+t
  Next  
  ProcedureReturn u
EndProcedure

Python

Python 2.x (but not 3.x) has built-in rot13 encoding and decoding:

Works with: Python version 2.x
>>> u'foo'.encode('rot13')
'sbb'
>>> 'sbb'.decode('rot13')
u'foo'

In both Python 2.x and 3.x one can use the standard library module codecs for rot13 encoding and decoding:

Works with: Python version 2.x
Works with: Python version 3.x
>>> import codecs
>>> codecs.encode("The quick brown fox jumps over the lazy dog", "rot13")
'Gur dhvpx oebja sbk whzcf bire gur ynml qbt'
>>> codecs.decode(_, "rot13")
'The quick brown fox jumps over the lazy dog'

An alternative that doesn't rely on the built-in "rot13" codec:

Works with: Python version 3.x
#!/usr/bin/env python
import string

TRANSLATION_TABLE = str.maketrans(
    string.ascii_uppercase + string.ascii_lowercase,
    string.ascii_uppercase[13:] + string.ascii_uppercase[:13] +
    string.ascii_lowercase[13:] + string.ascii_lowercase[:13]
)


def rot13(s):
    """Return the rot-13 encoding of s."""
    return s.translate(TRANSLATION_TABLE)


if __name__ == "__main__":
    """rot-13 encode the input files, or stdin if no files are provided."""
    import fileinput
    for line in fileinput.input():
        print(rot13(line), end="")

The str.translate() and str.maketrans() functions make the function's definition almost trivial. The fileinput module makes the wrapper functionality trivial to implement. This can be adapted for Python2.x by replacing str.maketrans with string.maketrans and using Python2 style print statement in place of the Python3 print function.

Works with: Python version 3.x
and
Works with: Python version 2.7

This one uses a dictionary comprehension to define the key for lowercase then another to updates with with uppercase mappings. It uses generator expression in a lambda as the encoding function and the dictionary .get() (with default value) to preserve any non-letter characters during encoding. This lambda line can be used to generate an encoding function for any substitution cipher defined in the name "key."

#!/usr/bin/env python
from __future__ import print_function
import string
lets = string.ascii_lowercase
key = {x:y for (x,y) in zip(lets[13:]+lets[:14], lets)}
key.update({x.upper():key[x].upper() for x in key.keys()})
encode = lambda x: ''.join((key.get(c,c) for c in x))
if __name__ == '__main__':
   """Peform line-by-line rot-13 encoding on any files listed on our
      command line or act as a standard UNIX filter (if no arguments
      specified).
   """
   import fileinput
   for line in fileinput.input():
      print(encode(line), end="")

QB64

CBTJD: 2020/03/14
By using the matching length inlist$ and outlist$ variables, any arbitrary replacement code can easily be implemented.

INPUT "Enter a string: ", a$
PRINT rot13$(a$)
FUNCTION rot13$ (stg$)
    inlist$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    outlist$ = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
    FOR n = 1 TO LEN(stg$)
        letter$ = MID$(stg$, n, 1)
        letpos = INSTR(inlist$, letter$)
        IF letpos = 0 THEN
            rotated$ = letter$
        ELSE
            rotated$ = MID$(outlist$, letpos, 1)
        END IF
        rot13$ = rot13$ + rotated$
    NEXT
END FUNCTION

Quackery

[ $ "" swap
  witheach
    [ dup  char A char M 1+ within
      over char a char m 1+ within or
      iff [ 13 + ]
      else
        [ dup  char N char Z 1+ within
          over char n char z 1+ within or
          if [ 13 - ] ]
      join ] ]                            is rot-13 ( $ --> $ )

Testing in Quackery shell.

/O> $ "five quacking zephyrs jolt my wax bed." carriage join
... $ "VAMP FOX HELD QUARTZ DUCK JUST BY WING." join
...        dup echo$ cr cr
... rot-13 dup echo$ cr cr
... rot-13     echo$ cr
... 
five quacking zephyrs jolt my wax bed.
VAMP FOX HELD QUARTZ DUCK JUST BY WING.

svir dhnpxvat mrculef wbyg zl jnk orq.
INZC SBK URYQ DHNEGM QHPX WHFG OL JVAT.

five quacking zephyrs jolt my wax bed.
VAMP FOX HELD QUARTZ DUCK JUST BY WING.

Stack empty.

R

rot13 <- function(x)
{
  old <- paste(letters, LETTERS, collapse="", sep="")
  new <- paste(substr(old, 27, 52), substr(old, 1, 26), sep="")
  chartr(old, new, x)
}
x <- "The Quick Brown Fox Jumps Over The Lazy Dog!.,:;'#~[]{}"
rot13(x)   # "Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt!.,:;'#~[]{}"
x2 <- paste(letters, LETTERS, collapse="", sep="")
rot13(x2)  # "nNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmM"

For a slightly more general function, see the example on the chartr help page.

Racket

#!/usr/bin/env racket
#lang racket/base

(define (run i o)
  (for ([ch (in-producer regexp-match #f #rx#"[a-zA-Z]" i 0 #f o)])
    (define b (bytes-ref (car ch) 0))
    (define a (if (< b 96) 65 97))
    (write-byte (+ (modulo (+ 13 (- b a)) 26) a))))

(require racket/cmdline)
(command-line
 #:help-labels "(\"-\" specifies standard input)"
 #:args files
 (for ([f (if (null? files) '("-") files)])
   (if (equal? f "-")
     (run (current-input-port) (current-output-port))
     (call-with-input-file f (λ(i) (run i (current-output-port)))))))

Raku

(formerly Perl 6)

my @abc = 'a'..'z';
my $abc = [@abc».uc, @abc];
put .trans: $abc => $abc».rotate(13) for lines

Input:

Rosetta Code

Output:

Ebfrggn Pbqr

RapidQ

function ROT13 (InputTxt as string) as string
    dim i as integer, ascVal as byte
    Result = ""
    
    for i = 1 to len(InputTxt)
        ascVal = asc(InputTxt[i])

        select case ascVal 
        case 65 to 77, 97 to 109
            Result = Result + chr$(ascVal + 13)
        case 78 to 90, 110 to 122
            Result = Result + chr$(ascVal - 13)
        case else
            Result = Result + chr$(ascVal)
        end select 
    next
end function

Input "Text to encode: "; a$
Print ROT13(a$)
Input "Press a key to end..."; a$

Raven

define rot13 use $str
    $str each chr
        dup m/[A-Ma-m]/ if
            ord 13 + chr
        else
            dup m/[N-Zn-z]/ if
               ord 13 - chr
    $str length list "" join

"12!ABJURER nowhere" 
dup print "\nas rot13 is\n" print 
rot13 
print "\n" print
Output:
12!ABJURER nowhere
as rot13 is
12!NOWHERE abjurer

REBOL

REBOL [
    Title: "Rot-13"
    URL: http://rosettacode.org/wiki/Rot-13
]

; Test data has upper and lower case characters as well as characters
; that should not be transformed, like numbers, spaces and symbols.

text: "This is a 28-character test!"

print "Using cipher table:"

; I build a set of correspondence lists here. 'x' is the letters from
; A-Z, in both upper and lowercase form. Note that REBOL can iterate
; directly over the alphabetic character sequence in the for loop. 'y'
; is the cipher form, 'x' rotated by 26 characters (remember, I have
; the lower and uppercase forms together). 'r' holds the final result,
; built as I iterate across the 'text' string. I search for the
; current character in the plaintext list ('x'), if I find it, I get
; the corresponding character from the ciphertext list
; ('y'). Otherwise, I pass the character through untransformed, then
; return the final string.

rot-13: func [
	"Encrypt or decrypt rot-13 with tables."
	text [string!] "Text to en/decrypt."
	/local x y r i c
] [
	x: copy ""  for i #"a" #"z" 1 [append x rejoin [i  uppercase i]]
	y: rejoin [copy skip x 26  copy/part x 26]
	r: copy ""

	repeat i text [append r  either c: find/case x i [y/(index? c)][i]]
	r
]

; Note that I am setting the 'text' variable to the result of rot-13
; so I can reuse it again on the next call. The rot-13 algorithm is
; reversible, so I can just run it again without modification to decrypt.

print ["    Encrypted:"  text: rot-13 text]
print ["    Decrypted:"  text: rot-13 text] 


print "Using parse:"

clamp: func [
	"Contain a value within two enclosing values. Wraps if necessary."
	x v y
][
	x: to-integer x  v: to-integer v  y: to-integer y
	case [v < x [y - v] v > y [v - y + x - 1] true v]
]

; I'm using REBOL's 'parse' word here. I set up character sets for
; upper and lower-case letters, then let parse walk across the
; text. It looks for matches to upper-case letters, then lower-case,
; then skips to the next one if it can't find either. If a matching
; character is found, it's mathematically incremented by 13 and
; clamped to the appropriate character range. parse changes the
; character in place in the string, hence this is a destructive
; operation.

rot-13: func [
	"Encrypt or decrypt rot-13 with parse."
	text [string!] "Text to en/decrypt. Note: Destructive!"
] [
	u: charset [#"A" - #"Z"]
	l: charset [#"a" - #"z"]

	parse text [some [
			i:                                          ; Current position.
			u (i/1: to-char clamp #"A" i/1 + 13 #"Z") | ; Upper case.
			l (i/1: to-char clamp #"a" i/1 + 13 #"z") | ; Lower case.
			skip]]                                      ; Ignore others.
	text
]

; As you see, I don't need to re-assign 'text' anymore.

print ["    Encrypted:" rot-13 text]
print ["    Decrypted:" rot-13 text]

Output:

Using cipher table:
    Encrypted: Guvf vf n 28-punenpgre grfg!
    Decrypted: This is a 28-character test!
Using parse:
    Encrypted: Guvf vf n 28-punenpgre grfg!
    Decrypted: This is a 28-character test!

Retro

{{
  : rotate  ( cb-c ) tuck - 13 + 26 mod + ;
  : rotate? (  c-c )
    dup 'a 'z within [ 'a rotate ] ifTrue
    dup 'A 'Z within [ 'A rotate ] ifTrue ;
---reveal---
  : rot13   (  s-s ) dup [ [ @ rotate? ] sip ! ] ^types'STRING each@ ;
}}

"abcdef123GHIJKL" rot13 dup puts cr rot13 puts
"abjurer NOWHERE" rot13 puts

REXX

This REXX version supports upper and lower case letters, preserves their case (upper/lower),
and passes through (without alteration) all non-alphabetic input characters.

/*REXX program  encodes  several example text strings  using  the  ROT-13  algorithm.   */
$='foo'                         ; say "simple text=" $;  say 'rot-13 text=' rot13($);  say
$='bar'                         ; say "simple text=" $;  say 'rot-13 text=' rot13($);  say
$="Noyr jnf V, 'rer V fnj Ryon."; say "simple text=" $;  say 'rot-13 text=' rot13($);  say
$='abc?  ABC!'                  ; say "simple text=" $;  say 'rot-13 text=' rot13($);  say
$='abjurer NOWHERE'             ; say "simple text=" $;  say 'rot-13 text=' rot13($);  say
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
rot13: return  translate( arg(1), 'abcdefghijklmABCDEFGHIJKLMnopqrstuvwxyzNOPQRSTUVWXYZ',,
                                  "nopqrstuvwxyzNOPQRSTUVWXYZabcdefghijklmABCDEFGHIJKLM")

output

simple text = foo
rot-13 text = sbb

simple text = bar
rot-13 text = one

simple text = Noyr jnf V, 'rer V fnj Ryon.
rot-13 text = Able was I, 'ere I saw Elba.

simple text = abc?  ABC!
rot-13 text = nop?  NOP!

simple text = abjurer NOWHERE
rot-13 text = nowhere ABJURER

Ring

see "enter a string : " give s
ans = ""
for a = 1 to len(s)
    letter = substr(s, a, 1)
    if letter >= "a" and letter <= "z" 
       char = char(ascii(letter) + 13)
       if char > "z" char = chr(asc(char) - 26) ok
    else  
       if letter >= "a" and letter <= "z" char = char(ascii(letter) + 13) ok
       if char > "z" char = char(ascii(char) - 26) else  char = letter ok
    ok
    ans = ans + char
next
see ans + nl

Ruby

# Returns a copy of _s_ with rot13 encoding.
def rot13(s)
  s.tr('A-Za-z', 'N-ZA-Mn-za-m')
end

# Perform rot13 on files from command line, or standard input.
while line = ARGF.gets
  print rot13(line)
end

One can run ruby rot13.rb file1 file2 to rot13 those files, or run ruby rot13.rb to rot13 the standard input.

Input:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Output:

NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm

Run BASIC

INPUT "Enter a string: "; s$
ans$ = ""
FOR a = 1 TO LEN(s$)
        letter$ = MID$(s$, a, 1)
        IF letter$ >= "A" AND letter$ <= "Z" THEN
           char$ = CHR$(ASC(letter$) + 13)
           IF char$ > "Z" THEN char$ = CHR$(ASC(char$) - 26)
        else  
           if letter$ >= "a" AND letter$ <= "z" THEN   char$ = CHR$(ASC(letter$) + 13)
           IF char$ > "z" THEN  char$ = CHR$(ASC(char$) - 26) ELSE  char$ = letter$
        END IF
        ans$ = ans$ + char$
NEXT a
PRINT ans$
Output:
Enter a string: ?abc
nop
Enter a string: ?ABC 
NOP

Rust

fn rot13(string: &str) -> String {
    string.chars().map(|c| {
        match c {
            'a'..='m' | 'A'..='M' => ((c as u8) + 13) as char,
            'n'..='z' | 'N'..='Z' => ((c as u8) - 13) as char,
            _ => c
        }
    }).collect()
}

fn main () {
    assert_eq!(rot13("abc"), "nop");
}

S-BASIC

comment
  Return the rot13 transformation of s, preserving case and
  passing non-alphabetic characters without change
end

function rot13(s = string) = string
  var i, k = integer
  var ch = char
  var normal, rotated = string
  normal  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  rotated = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
  for i = 1 to len(s)
    ch = mid(s,i,1)
    k = instr(1,normal,ch)
    if k <> 0 then ch = mid(rotated,k,1)
    mid(s,i,1) = ch
  next i
end = s

rem - exercise the function

var plain, encoded = string

plain = "The quick brown fox jumps over the lazy red dog."
encoded = rot13(plain)
print "Plain text: "; plain
print "Encoded   : "; encoded
print "Decoded   : "; rot13(encoded)

end
Output:
Plain text: The quick brown fox jumps over the lazy red dog.
Encoded   : Gur dhvpx oebja sbk whzcf bire gur ynml erq qbt.
Decoded   : The quick brown fox jumps over the lazy red dog.

An alternate approach

Rather than use a lookup table, we can assume the ASCII character set and rely on simple arithmetic for the transformation. In S-BASIC, char is synonymous with byte, allowing us to perform addition and subtraction directly on characters as though they were numbers, and eliminating the necessity of coding, for example, ch = chr(asc(ch) + 13) as required by many BASIC dialects.

comment
   Return the rot13 transformation of s, preserving case and 
   passing non-alphabetic characters unchanged.
end

function rot13(s = string) = string
  var i = integer
  var ch = char
  for i=1 to len(s)
    ch = mid(s,i,1)
    if (ch >= 'a' and ch <= 'm') or (ch >= 'A' and ch <= 'M') then
      ch = ch + 13
    else if (ch >= 'n' and ch <= 'z') or (ch >= 'N' and ch <= 'Z') then
      ch = ch - 13
    mid(s,i,1) = ch
  next i
end = s

rem - exercise the routine

var plain, rotated = string
plain = "The quick brown fox jumps over the lazy red dog."
rotated = rot13(plain)
print "Plain text: "; plain
print "Rotated   : "; rotated
print "Restored  : "; rot13(rotated)

end
Output:
Plain text: The quick brown fox jumps over the lazy red dog.
Rotated   : Gur dhvpx oebja sbk whzcf bire gur ynml erq qbt.
Restored  : The quick brown fox jumps over the lazy red dog.

S-lang

Seems to work even with UTF-8 text.

variable old = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
variable new = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";

define rot13(s) {
  s = strtrans(s, old, new);
  return s;
}

define rot13_stream(s) {
  variable ln;
  while (-1 != fgets(&ln, s))
    fputs(rot13(ln), stdout);
}

if (__argc > 1) {
  variable arg, fp;
  foreach arg (__argv[[1:]]) {
    fp = fopen(arg, "r");
    rot13_stream(fp);
  }
}
else
  rot13_stream(stdin);

Scala

scala> def rot13(s: String) = s map {
     |   case c if 'a' <= c.toLower && c.toLower <= 'm' => c + 13 toChar
     |   case c if 'n' <= c.toLower && c.toLower <= 'z' => c - 13 toChar
     |   case c => c
     | }
rot13: (s: String)String

scala> rot13("7 Cities of Gold.")
res61: String = 7 Pvgvrf bs Tbyq.

scala> rot13(res61)
res62: String = 7 Cities of Gold.

Scheme

(define (rot13 str)
  (define (rot13-char c)
    (integer->char (+ (char->integer c)
                      (cond ((and (char>=? c #\a) (char<? c #\n))
                             13)
                            ((and (char>=? c #\A) (char<? c #\N))
                             13)
                            ((and (char>=? c #\n) (char<=? c #\z))
                             -13)
                            ((and (char>=? c #\N) (char<=? c #\Z))
                             -13)
                            (else
                             0)))))
  (list->string (map rot13-char (string->list str))))

sed

The two translations (upper and lower case) are separate only for documentation and ease of understanding; they could be combined into one command.

y/abcdefghijklmnopqrstuvwxyz/nopqrstuvwxyzabcdefghijklm/
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/NOPQRSTUVWXYZABCDEFGHIJKLM/

Seed7

This rot13 program reads from standard input and writes to standard output:

$ include "seed7_05.s7i";

const proc: main is func
  local
    var char: ch is ' ';
  begin
    ch := getc(IN);
    while not eof(IN) do
      if (ch >= 'a' and ch <= 'm') or (ch >= 'A' and ch <= 'M') then
        ch := chr(ord(ch) + 13);
      elsif (ch >= 'n' and ch <= 'z') or (ch >= 'N' and ch <= 'Z') then
        ch := chr(ord(ch) - 13);
      end if;
      write(ch);
      ch := getc(IN);
    end while;
  end func;

Sidef

# Returns a copy of 's' with rot13 encoding.
func rot13(s) {
    s.tr('A-Za-z', 'N-ZA-Mn-za-m');
}

# Perform rot13 on standard input.
STDIN.each { |line| print rot13(line) }

Simula

    TEXT PROCEDURE ROT13(INP); TEXT INP;
    BEGIN

        CHARACTER PROCEDURE ROT13CHAR(C); CHARACTER C;
            ROT13CHAR :=
                CHAR(
                    RANK(C) +
                       (IF C >= 'A' AND C <= 'M' THEN  13 ELSE
                        IF C >= 'a' AND C <= 'm' THEN  13 ELSE
                        IF C >= 'N' AND C <= 'Z' THEN -13 ELSE
                        IF C >= 'n' AND C <= 'z' THEN -13 ELSE 0));

        TEXT OUTP;
        OUTP :- BLANKS(INP.LENGTH);

        INP.SETPOS(1);
        WHILE INP.MORE DO
            OUTP.PUTCHAR(ROT13CHAR(INP.GETCHAR));

        ROT13 :- OUTP;
    END ROT13;

Slate

A shell script:

#!/usr/local/bin/slate

ch@(String Character traits) rot13
[| value |
  upper ::= ch isUppercase.
  value := ch toLowercase as: Integer.
  (value >= 97) /\ [value < 110]
    ifTrue: [value += 13]
    ifFalse: [(value > 109) /\ [value <= 122]
                ifTrue: [value -= 13]].
  upper
    ifTrue: [(value as: String Character) toUppercase]
    ifFalse: [value as: String Character]
].

lobby define: #Rot13Encoder &parents: {Encoder}.

c@(Rot13Encoder traits) convert
[
  [c in isAtEnd] whileFalse: [c out nextPut: c in next rot13].
].

(Rot13Encoder newFrom: Console reader to: Console writer) convert.

Normal functions:

ch@(String Character traits) rot13
[| value |
  upper ::= ch isUppercase.
  value := ch toLowercase as: Integer.
  (value >= 97) /\ [value < 110]
    ifTrue: [value += 13]
    ifFalse: [(value > 109) /\ [value <= 122]
                ifTrue: [value -= 13]].
  upper
    ifTrue: [(value as: String Character) toUppercase]
    ifFalse: [value as: String Character]
].

s@(String traits) rot13
[
  result ::= s newSameSize.
  s doWithIndex: [| :each :index | result at: index put: each rot13].
  result
].

slate[37]> 'abc123' rot13.
'nop123'

Slope

Translation of: Go
(define rot-char-13 (lambda (ch)
  (set! ch (string->rune ch))
  (cond
    (
      (or
        (and (>= ch (string->rune "a")) (<= ch (string->rune "m")))
        (and (>= ch (string->rune "A")) (<= ch (string->rune "M"))))
      (rune->string (+ ch 13)))
    (
      (or
        (and (>= ch (string->rune "n")) (<= ch (string->rune "z")))
        (and (>= ch (string->rune "N")) (<= ch (string->rune "Z"))))
      (rune->string (- ch 13)))
    (else (rune->string ch)))))

(display (list->string (map rot-char-13 (string->list "nowhere->ABJURER!"))))
Output:
abjurer->NOWHERE!

Smalltalk

Works with: GNU Smalltalk

Here we implemented three ways. The first one is the simplest. The second demonstrates extending the String class with a generic rot method, which in turn uses two new method for the class Character (+ and -). The third one is an imitation of the tr '[a-m][n-z]' '[n-z][a-m]' approach (see UNIX Shell example), done through a block closure and using also the new method trFrom:to: for Character.

"1. simple approach"
rot13 := [ :string |
  string collect: [ :each | | index |
    index := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 
      indexOf: each ifAbsent: [ 0 ]. "Smalltalk uses 1-based indexing" 
        index isZero
          ifTrue: [ each ]
          ifFalse: [ 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM' at:
            index ] ] ].

(rot13 value: 'Test123') printNl "gives 'Grfg123'"

"2. extending built-in classes"
Character extend [
  + inc [
     (inc isKindOf: Character)
     ifTrue: [
        ^ ( Character value: ((self asInteger) + (inc asInteger)) )
     ] ifFalse: [
       ^ ( Character value: ((self asInteger) + inc) )
     ]
  ]
  - inc [
    ^ ( self + (inc asInteger negated) )
  ]
  trFrom: map1 to: map2 [
     (map1 includes: self) ifTrue: [
        ^ map2 at: (map1 indexOf: self)
     ] ifFalse: [ ^self ]
  ]
].

String extend [
  rot: num [ |s|
    s := String new.
    self do: [ :c |
         ((c asLowercase) between: $a and: $z)
	   ifTrue: [ |c1|
              c1 := ( $a + ((((c asLowercase) - $a + num) asInteger) rem:26)).
              (c isLowercase) ifFalse: [ c1 := c1 asUppercase ].
              s := s, (c1 asString)
           ]
           ifFalse: [
	      s := s, (c asString)
           ]
     ].
     ^s
  ]
].

('abcdefghijklmnopqrstuvwxyz123!' rot: 13) displayNl.
(('abcdefghijklmnopqrstuvwxyz123!' rot: 13) rot: 13) displayNl.



"2. using a 'translation'. Not very idiomatic Smalltalk code"
rotThirteen := [ :s | |m1 m2 r|
  r := String new.
  m1 := OrderedCollection new.
  0 to: 25 do: [ :i | m1 add: ($a + i) ].
  m2 := OrderedCollection new.
  0 to: 25 do: [ :i | m2 add: ($a + ((i+13) rem: 26)) ].
  s do: [ :c |
    (c between: $a and: $z) | (c between: $A and: $Z)
      ifTrue: [ | a |
        a := (c asLowercase) trFrom: m1 to: m2.
        (c isUppercase) ifTrue: [ a := a asUppercase ].
        r := r, (a asString)] 
      ifFalse: [ r := r, (c asString) ]
  ].
  r
].

(rotThirteen value: 'abcdefghijklmnopqrstuvwxyz123!') displayNl.

SNOBOL4

Works with: Macro Spitbol
Works with: Snobol4+
Works with: CSnobol
*       # Function using replace( )
        define('rot13(s)u1,u2,l1,l2') :(rot13_end)
rot13   &ucase len(13) . u1 rem . u2
        &lcase len(13) . l1 rem . l2
        rot13 = replace(s,&ucase &lcase,u2 u1 l2 l1) :(return)
rot13_end

*       # Function using pattern
        define('rot13s(s)c')
        alfa = &ucase &ucase &lcase &lcase :(rot13s_end)
rot13s  s len(1) . c = :f(return)
        alfa break(c) len(13) len(1) . c
        rot13s = rot13s c :(rot13s)
rot13s_end

*       # Test and display both
        str = rot13("I abjure the $19.99 trinket!")
        output = str; output = rot13(str)
        str = rot13s("He's a real Nowhere Man.")
        output = str; output = rot13s(str)
end

Output:

V nowher gur $19.99 gevaxrg!
I abjure the $19.99 trinket!
Ur'f n erny Abjurer Zna.
He's a real Nowhere Man.

SQL

select translate(
        'The quick brown fox jumps over the lazy dog.',
        'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
        'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'
        )
        from dual;
Works with: T-SQL
with cte(num) as 
(
 select 1
 union all
 select num+1
 from cte
)
select cast((
select char(ascii(chr) +
		case 
			when    ascii(chr) between ascii('a') and ascii('m') or
				ascii(chr) between ascii('A') and ascii('M') then 13
			when    ascii(chr) between ascii('n') and ascii('z') or
				ascii(chr) between ascii('N') and ascii('Z') then -13
			else    0
		end)
from
(
select top(1000) num, 
		 -- your string to be converted to ROT13
                 substring('The Quick Brown Fox Jumps Over The Lazy Dog',num,1) chr
from cte
) tmp
For XML PATH ('')) as xml).value('.', 'VARCHAR(max)') rot13
option (maxrecursion 0)

Stata

function rot13(s) {
	u = ascii(s)
	i = selectindex(u:>64 :& u:<91)
	if (length(i)>0) u[i] = mod(u[i]:-52, 26):+65
	i = selectindex(u:>96 :& u:<123)
	if (length(i)>0) u[i] = mod(u[i]:-84, 26):+97
	return(char(u))
}

rot13("Shall Not Perish")
  Funyy Abg Crevfu

Swift

func rot13char(c: UnicodeScalar) -> UnicodeScalar {
  switch c {
  case "A"..."M", "a"..."m":
    return UnicodeScalar(UInt32(c) + 13)
  case "N"..."Z", "n"..."z":
    return UnicodeScalar(UInt32(c) - 13)
  default:
    return c
  }
}

func rot13(str: String) -> String {
  return String(map(str.unicodeScalars){ c in Character(rot13char(c)) })
}

println(rot13("The quick brown fox jumps over the lazy dog"))
Output:
Gur dhvpx oebja sbk whzcf bire gur ynml qbt

Tcl

tcl-only

using string map:

proc rot13 line {
    string map {
        a n b o c p d q e r f s g t h u i v j w k x l y m z
        n a o b p c q d r e s f t g u h v i w j x k y l z m
        A N B O C P D Q E R F S G T H U I V J W K X L Y M Z
        N A O B P C Q D R E S F T G U H V I W J X K Y L Z M
    } $line
}
set tx "Hello, World !"
puts "$tx : [rot13 $tx]"
Output:
Hello, World ! : Uryyb, Jbeyq !

Library: TclX

using translit:

package require Tclx
proc rot13 str {
    translit "A-Za-z" "N-ZA-Mn-za-m" $str
}

TI-83 BASIC

Calculator symbol translations:

"STO" arrow: →

Perfoms ROT-13 on the contents of Str1. Also uses the string variables Str0 and Str2 and the real variable N.

:"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str0
:".→Str2
:For(N,1,length(Str1
:If inString(Str0,sub(Str1,N,1
:Then
:inString(Str0,sub(Str1,N,1
:Ans+13-26(Ans>13
:Str2+sub(Str0,Ans,1→Str2
:Else
:Str2+sub(Str1,N,1→Str2
:End
:End
:sub(Str2,2,length(Str2)-1→Str1

TorqueScript

--Ipquarx 8:45 PM

function rot13(%string)
{
	%alph = "abcdefghijklmnopqrstuvwxyz";
	%len = strLen(%string);
	
	for(%a = 0; %a < %len; %a++)
	{
		%char = getSubStr(%string,%a,1);
		%pos = striPos(%alph, %char);

		if(%pos < 0)
			%out = %out @ %char;
		else
		{
			if(strPos(%alph, %char) < 0)
				%out = %out @ strUpr(getSubStr(%alph, (%pos + 13) % 26));
			else
				%out = %out @ getSubStr(%alph, (%pos + 13) % 26);
		}
	}
	return %out;
}

TXR

Via definition and subsequent use of a named filter.

@(deffilter rot13 
   ("a" "n") ("b" "o") ("c" "p") ("d" "q") ("e" "r") ("f" "s") ("g" "t")
   ("h" "u") ("i" "v") ("j" "w") ("k" "x") ("l" "y") ("m" "z") ("n" "a")
   ("o" "b") ("p" "c") ("q" "d") ("r" "e") ("s" "f") ("t" "g") ("u" "h")
   ("v" "i") ("w" "j") ("x" "k") ("y" "l") ("z" "m")
   ("A" "N") ("B" "O") ("C" "P") ("D" "Q") ("E" "R") ("F" "S") ("G" "T")
   ("H" "U") ("I" "V") ("J" "W") ("K" "X") ("L" "Y") ("M" "Z") ("N" "A")
   ("O" "B") ("P" "C") ("Q" "D") ("R" "E") ("S" "F") ("T" "G") ("U" "H")
   ("V" "I") ("W" "J") ("X" "K") ("Y" "L") ("Z" "M"))
@(repeat)
@line
@  (output :filter rot13)
@line
@  (end)
@(end)

Via TXR Lisp:

(defun rot13 (ch)
  (cond
    ((<= #\A ch #\Z) (wrap #\A #\Z (+ ch 13)))
    ((<= #\a ch #\z) (wrap #\a #\z (+ ch 13)))
    (t ch)))

   (whilet ((ch (get-char)))
     (put-char (rot13 ch)))

UNIX Shell

Bourne Shell

UNIX shell assumes availability of the standard UNIX utility commands (in the "coreutils" package on Linux systems, for example); thus the tr (translate) command is trivially provided with the proper arguments to perform the rotations.

POSIX compliant

Built from six rotonyms.

tr \
'NOWHERE AZ clerk IRAQ faber gnat ABJURER NM pyrex VEND snore tang'\
'abjurer nm PYREX vend SNORE TANG nowhere az CLERK iraq FABER GNAT' \
'ABJURER NM pyrex VEND snore tang NOWHERE AZ clerk IRAQ faber gnat'\
'nowhere az CLERK iraq FABER GNAT abjurer nm PYREX vend SNORE TANG'

Not POSIX compliant

#!/bin/sh
rot13() {
   tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]'
}

cat ${1+"$@"} | rot13

A simple tr a-zA-Z n-za-mN-ZA-M would work with modern systems that follow POSIX. Our tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]' also works with those older System V systems. For newer systems, it translates '[' and ']' to themselves. (Refer to OpenBSD tr(1) manual page, section STANDARDS.)

This example shows proper quoting around "$@" (magical argument list) such that this script work properly even if some of the files named on the command line contain embedded spaces or other such characters. (The ${1+"$@"} check, unnecessary in modern systems, allows the script to work even on older systems where a bare "$@" expanded to a single empty string when no arguments were supplied).

Unlambda

``ci`d``@i`c``s`d```?aic.n``s`d```?bic.o``s`d```?cic.p``s`d```?dic.q``s`d```?eic
.r``s`d```?fic.s``s`d```?gic.t``s`d```?hic.u``s`d```?iic.v``s`d```?jic.w``s`d```
?kic.x``s`d```?lic.y``s`d```?mic.z``s`d```?nic.a``s`d```?oic.b``s`d```?pic.c``s`
d```?qic.d``s`d```?ric.e``s`d```?sic.f``s`d```?tic.g``s`d```?uic.h``s`d```?vic.i
``s`d```?wic.j``s`d```?xic.k``s`d```?yic.l``s`d```?zic.m``s`d```?Nic.A``s`d```?O
ic.B``s`d```?Pic.C``s`d```?Qic.D``s`d```?Ric.E``s`d```?Sic.F``s`d```?Tic.G``s`d`
``?Uic.H``s`d```?Vic.I``s`d```?Wic.J``s`d```?Xic.K``s`d```?Yic.L``s`d```?Zic.M``
s`d```?Aic.N``s`d```?Bic.O``s`d```?Cic.P``s`d```?Dic.Q``s`d```?Eic.R``s`d```?Fic
.S``s`d```?Gic.T``s`d```?Hic.U``s`d```?Iic.V``s`d```?Jic.W``s`d```?Kic.X``s`d```
?Lic.Y``s`d```?Mic.Z`d`|c

Ursala

I/O in Ursala is meant to be handled automatically as much as possible by the run time system. This source text describes only a function that operates on the contents of a list of files passed to it as an argument, with the transformed files returned as a result. The #executable compiler directive and its parameters mean that this source will be compiled to an executable file with the required command line interface. The rot13 encryption algorithm itself is a simple finite map implemented in a half line of code.

#import std

#executable (<'parameterized','default-to-stdin'>,<>)

rot = ~command.files; * contents:= ~contents; * * -:~& -- ^p(~&,rep13~&zyC)~~ ~=`A-~ letters

Vala

string rot13(string s) {
  const string lcalph = "abcdefghijklmnopqrstuvwxyz";
  const string ucalph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string result = "";
  int pos;
  unichar c;
  
  for (int i = 0; s.get_next_char (ref i, out c);) {
    if ((pos = lcalph.index_of_char(c)) != -1)
      result += lcalph[(pos + 13) % 26].to_string();
    else if ((pos = ucalph.index_of_char(c)) != -1)
      result += ucalph[(pos + 13) % 26].to_string();
    else
      result += c.to_string();
  }

  return result;
}

void main() {
  print(rot13("The Quick Brown Fox Jumped Over the Lazy Dog!"));
}
Output:
Gur Dhvpx Oebja Sbk Whzcrq Bire gur Ynml Qbt!

Vedit macro language

Using ROT13.TBL from here

Translate_Load("ROT13.TBL")
Translate_Block(0, File_Size)

You can execute the macro from DOS command prompt with the following command:

vpw -q -x rot13.vdm inputfile -a outputfile

In addition to translating a block of text, the translate table allows viewing and editing ROT-13 text without translating the actual file into ASCII. The displayed characters and keyboard input are translated on-the-fly. This is the normal way to edit for example DOS/OEM and EBCDIC files.

Visual Basic

Works with: Visual Basic version VB6 Standard
Function ROT13(ByVal a As String) As String
  Dim i As Long
  Dim n As Integer, e As Integer

  ROT13 = a
  For i = 1 To Len(a)
    n = Asc(Mid$(a, i, 1))
    Select Case n
      Case 65 To 90
        e = 90
        n = n + 13
      Case 97 To 122
        e = 122
        n = n + 13
      Case Else
        e = 255
    End Select
  
    If n > e Then
      n = n - 26
    End If
    Mid$(ROT13, i, 1) = Chr$(n)
  Next i
End Function

Testing:

Sub Main()
  Debug.Assert ROT13("abc") = "nop"
  Debug.Assert ROT13("nop") = "abc"
End Sub

Visual Basic .NET

Platform: .NET

Works with: Visual Basic .NET version 9.0+
Module Module1

   Private Function rot13(ByVal str As String) As String
       Dim newChars As Char(), i, j As Integer, original, replacement As String

       original = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
       replacement = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"

       newChars = str.ToCharArray()

       For i = 0 To newChars.Length - 1
           For j = 0 To 51
               If newChars(i) = original(j) Then
                   newChars(i) = replacement(j)
                   Exit For
               End If
           Next
       Next

       Return New String(newChars)
   End Function

End Module

This solution just uses simple textual substitution, since the number of characters involved is small. If the cipher involved more characters, it would be better to use character arithmetic; however, this is not encouraged in VB.Net.

VBScript

option explicit 

function rot13(a)
  dim b,n1,n,i
  b=""
  for i=1 to len(a)
    n=asc(mid(a,i,1))
    if n>=65 and n<= 91 then
       n1=(((n-65)+13)mod 26)+65
    elseif n>=97 and n<= 123 then
       n1=(((n-97)+13)mod 26)+97
    else
        n1=n
    end if
    b=b & chr(n1)
  next  
  rot13=b
end function

const a="The quick brown fox jumps over the lazy dog."
dim b,c
wscript.echo a 
b=rot13(a)
wscript.echo b    
c=rot13(b)
wscript.echo c
Output:
The quick brown fox jumps over the lazy dog.
Gur dhvpx oebja sbk whzcf bire gur ynml qbt.
The quick brown fox jumps over the lazy dog.

Vlang

fn main() {
	println(rot13('nowhere ABJURER'))
	println(rot13('abjurer NOWHERE'))
}

fn rot13char(chr u8) u8 {
	if (chr >= u8(97) && chr <= u8(109)) || (chr >= u8(65) && chr <= u8(77)) {
		return chr + 13
	} 
	if (chr >= u8(110) && chr <= u8(122)) || (chr >= u8(78) && chr <= u8(90)) {
		return chr - 13
	}
	return chr
}

fn rot13(str string) string {
	mut chr_arr := []u8{}
	for elem in str.split('') {
		chr_arr << rot13char(elem.str) 
	}
	return chr_arr.bytestr()
}
Output:
abjurer NOWHERE
nowhere ABJURER

Wart

def (rot13 s)
  (as string
      (map rot13
           (as list s)))

Alphabet <- "abcdefghijklmnopqrstuvwxyz"
def (rot13 c) :case (and string?.c len.c=1)
  if ("a" <= c <= "z")
       let idx (pos c Alphabet)
         Alphabet (idx+13 % 26)
     ("A" <= c <= "Z")
       (downcase.c -> rot13 -> upcase)
     :else
       c

Output:

(rot13 "Moron")
=> "Zbeba"

Whenever

1 2#read()-N(2);
2 2;
3 defer(1 || N(2) > 90 || N(2) < 65) 5#65-N(5);
4 defer(1 || N(2) > 122 || N(2) < 97) 5#97-N(5);
5 5;
6 defer(3 && 4) put(U(((N(2) - N(5) + 13) % 26) + N(5)));
7 defer(1 || N(2) > 64 || N(2) == 0) put(U(N(2)));
8 again(8) defer(6 && 7) 1,-6#N(6)-1,-7#N(7)-1,-3#N(3)-1,-4#N(4)-1;
9 defer(1 || N(2) != 0) -3,-4,-5#N(5),-6,-7,-8;
10 defer(1 || 9) put("\n");


Whitespace

To exit, type the character '`'

Wren

var rot13 = Fn.new { |s|
    var bytes = s.bytes.toList
    for (i in 0...bytes.count) {
        var c = bytes[i]
        if ((c >= 65 && c <= 77) || (c >= 97 && c <= 109)) {
            bytes[i] = c + 13
        } else if ((c >= 78 && c <= 90) || (c >= 110 && c <= 122)) {
            bytes[i] = c - 13
        }
    }
    return bytes.map { |b| String.fromByte(b) }.join()
}

System.print(rot13.call("nowhere ABJURER"))
Output:
abjurer NOWHERE

X86 Assembly

Using Linux/FASM.

format 	ELF 	executable 3
entry 	start
	
segment	readable writeable
buf	rb	1
	
segment	readable executable
start:	mov	eax, 3		; syscall "read"
	mov	ebx, 0		; stdin
	mov	ecx, buf	; buffer for read byte
	mov	edx, 1		; len (read one byte)
	int	80h

	cmp	eax, 0		; EOF?
	jz	exit

	xor 	eax, eax	; load read char to eax
	mov	al, [buf]
	cmp	eax, "A"	; see if it is in ascii a-z or A-Z
	jl	print
	cmp	eax, "z"
	jg	print
	cmp	eax, "Z"
	jle	rotup
	cmp	eax, "a"
	jge	rotlow
	jmp	print

rotup:	sub	eax, "A"-13	; do rot 13 for A-Z
	cdq
	mov	ebx, 26
	div	ebx
	add	edx, "A"
	jmp	rotend
	
rotlow:	sub	eax, "a"-13	; do rot 13 for a-z
	cdq
	mov	ebx, 26
	div	ebx
	add	edx, "a"

rotend:	mov	[buf], dl
	
print: 	mov	eax, 4		; syscall write
	mov	ebx, 1		; stdout
	mov	ecx, buf	; *char
	mov	edx, 1		; string length
	int	80h

	jmp	start

exit: 	mov     eax,1		; syscall exit
	xor     ebx,ebx		; exit code
	int     80h

XPL0

Usage: rot13 <infile.txt >outfile.txt

code    ChIn=7, ChOut=8;
int     C, CC;
repeat  C:= ChIn(1);  CC:= C&~$20;  \CC handles lowercase too
        ChOut(0, C + (if CC>=^A & CC<=^M then +13
                 else if CC>=^N & CC<=^Z then -13
                 else 0));
until   C = $1A;  \EOF

XSLT

Textual transforms are one of the domains XSLT was designed for.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text" />
  <xsl:variable name="alpha">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</xsl:variable>
  <xsl:variable name="rot13">NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm</xsl:variable>  
  <xsl:template match="body"> 
    <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="rot13">
    <xsl:value-of select="translate(.,$alpha,$rot13)"/>
  </xsl:template>
</xsl:stylesheet>

This will transform the input:

<body>The <rot13>Abjurer</rot13> was to be found <rot13>Nowhere</rot13>.</body>

into:

The Nowhere was to be found Abjurer.


Yabasic

s$ = "nowhere ABJURER"
print " Cadena original : ", s$
print "  Tras codificar : ", Rot13$(s$)
print "Tras decodificar : ", Rot13$(Rot13$(s$))
end

sub Rot13$ (s$)
    local cad$
    cad$ = ""
    
    for i = 1 to len(s$)
        temp = asc(mid$(s$, i, 1))
        
        if temp >= 65 and temp <= 90 then      // A to Z
            temp = (mod((temp - 52), 26)) + 65
        elsif temp >= 97 And temp <= 122 then  // a to z 
            temp = (mod((temp - 84), 26)) + 97
        end if
        cad$ = cad$ + chr$(temp)
    next i
    return cad$
end sub
Output:
 Cadena original : nowhere ABJURER
  Tras codificar : abjurer NOWHERE
Tras decodificar : nowhere ABJURER


zig

// Warning: modifies the buffer in-place (returns pointer to in)
fn rot13(in: [] u8) []u8 {
    for (in) |*c| {
        var d : u8 = c.*;
        var x : u8 = d;
        x = if (@subWithOverflow(u8, d | 32, 97, &x) ) x else x;
        if (x < 26) {
            x = (x + 13) % 26 + 65 + (d & 32);
            c.* = x;
        }        
    }
    return in;
}

const msg: [:0] const u8 = 
    \\Lbh xabj vg vf tbvat gb or n onq qnl
    \\ jura gur yrggref va lbhe nycunorg fbhc
    \\ fcryy Q-V-F-N-F-G-R-E.
;

// need to copy the const string to a buffer
// before we can modify it in-place
//https://zig.news/kristoff/what-s-a-string-literal-in-zig-31e9

var buf: [500]u8 = undefined;
fn assignStr(out: []u8, str: [:0]const u8) void {
    for (str) |c, i| {
        out[i] = c;
    }
    out[str.len] = 0;
}

const print = @import("std").debug.print;

pub fn main() void {
    assignStr(&buf, msg);
    print("rot13={s}\n",.{rot13(&buf)});
}

zkl

File rot13.zkl:

#!/home/craigd/Bin/zkl
fcn rot13(text){
   text.translate("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
   		  "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM");
}
text:=(vm.arglist or File.stdin);  // command line or pipe
text.pump(File.stdout,rot13);      // rotate each word and print it
if(text.isType(List)) File.stdout.writeln();	// command line gets ending newline
$ ./rot13.zkl "Hello World!"
Uryyb Jbeyq!

$ ./rot13.zkl Hello " " 'World!'
Uryyb Jbeyq!

$ echo "Uryyb Jbeyq!" | ./rot13.zkl
Hello World!

$ ./rot13.zkl < rot13.zkl
#!/ubzr/penvtq/Ova/mxy
spa ebg13(grkg){
   grkg.genafyngr("nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM",
   		  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
grkg:=(iz.netyvfg be Svyr.fgqva);  // pbzznaq yvar be cvcr
grkg.chzc(Svyr.fgqbhg,ebg13);      // ebgngr rnpu jbeq naq cevag vg
vs(grkg.vfGlcr(Yvfg)) Svyr.fgqbhg.jevgrya();	// pbzznaq yvar trgf raqvat arjyvar

Zoea

program: rot13 
  case: 1
        input: abc 
        output: nop 
  case: 2 
        input: nop 
        output: abc 
  case: 3 
        input: 'ABC' 
        output: 'NOP' 
  case: 4 
        input: 'NOP' 
        output: 'ABC'

Zoea Visual

Rot-13

ZX Spectrum Basic

Translation of: QBasic
10 CLS
20 INPUT "Enter a string: ", s$
30 LET a$ = "": REM a$ is the encoded string
40 FOR l = 1 TO LEN(s$)
50 LET i$ = s$(l): REM i$ is the letter being worked on
60 IF i$ < "A" OR i$ > "Z" THEN GO TO 100
70 LET c$ = CHR$(CODE(i$) + 13): REM c$ is the encoded letter
80 IF c$ > "Z" THEN LET c$ = CHR$(CODE(c$) - 26)          
90 GO TO 300
100 IF i$ < "a" OR i$ > "z" THEN GO TO 200
110 LET c$ = CHR$(CODE(i$) + 13)          
120 IF c$ > "z" THEN LET c$ = CHR$(CODE(c$) - 26)          
130 GO TO 300
200 LET c$ = i$
300 LET a$ = a$ + c$
310 NEXT l
320 PRINT a$