kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Rot-13
C++: #include <iostream>
#include <istream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>


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;
}




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();
}


int main(int argc, char* argv[])
{
  if (argc == 1) 
    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())
        
        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;
}

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;
    }
}
Task: Rot-13
C++: #include <iostream>
#include <istream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>


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;
}




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();
}


int main(int argc, char* argv[])
{
  if (argc == 1) 
    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())
        
        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;
}

Python: >>> u'foo'.encode('rot13')
'sbb'
>>> 'sbb'.decode('rot13')
u'foo'
Task: Rot-13
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;
    }
}

VB: 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$
Task: Rot-13
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"))
}

Python: >>> u'foo'.encode('rot13')
'sbb'
>>> 'sbb'.decode('rot13')
u'foo'
Task: Rot-13
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"))
}

VB: 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$
Task: Rot-13
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()));
        }
    }
}

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"))
}
Task: Rot-13
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()));
        }
    }
}

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;
    }
}
Task: Rot-13
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()));
        }
    }
}

Python: >>> u'foo'.encode('rot13')
'sbb'
>>> 'sbb'.decode('rot13')
u'foo'
Task: Rot-13
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"))
}

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;
    }
}
Task: Rot-13
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;
    }
}

Python: >>> u'foo'.encode('rot13')
'sbb'
>>> 'sbb'.decode('rot13')
u'foo'
Task: Rot-13
C: #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;
}

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"))
}
Task: Rot-13
C++: #include <iostream>
#include <istream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>


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;
}




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();
}


int main(int argc, char* argv[])
{
  if (argc == 1) 
    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())
        
        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;
}

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"))
}
Task: Rot-13
C++: #include <iostream>
#include <istream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>


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;
}




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();
}


int main(int argc, char* argv[])
{
  if (argc == 1) 
    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())
        
        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;
}

VB: 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$
Task: Rot-13
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()));
        }
    }
}

VB: 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$
Task: Rot-13
Python: >>> u'foo'.encode('rot13')
'sbb'
>>> 'sbb'.decode('rot13')
u'foo'

VB: 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$
Task: Rot-13
C: #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;
}

PHP: echo str_rot13('foo'), "\n";
Task: Rot-13
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()));
        }
    }
}

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