g | x | w | all
Bytes Lang Time Link
017Juby250521T173735ZJordan
083MSSQL250521T165847ZBradC
071AWK250521T160335Zxrs
017Itr230802T164157Zbsoelch
005Japt180920T164336ZShaggy
00305AB1E190409T064855ZKevin Cr
015x8616 machine code190409T151157Z640KB
053JavaScript Node.js230801T111007Zl4m2
006Vim230727T232006ZHunaphu
002Thunno 2230621T164420ZThe Thon
017K ngn/k201231T175440Zcoltim
029MATLAB/Octave210511T185818Zelementi
044Acc!!210510T001821ZDLosc
nanmmo MMIX executable210509T234722ZNoLonger
059C gcc210507T024505ZYelp
112batch210506T151959ZT3RR0R
113///210506T145128Zsporkl
028Julia210506T135648ZMarcMush
002Vyxal210506T123857Zlyxal
090naz200125T204620Zsporebal
029FALSE201231T213238ZReedsSho
3930J190409T142648ZJonah
048Python 3131006T163341ZRy-
043PowerShell180919T135053Zmazzy
9290JavaScriptES6190411T001316ZRouli Fr
017><>190409T131651ZEmigna
055Forth gforth190409T122206Zreffu
058JavaScript190408T193418Z12Me21
037q180920T211138ZThaufeki
078Python 3160212T145719ZArgenis
9110Perl160212T022218ZCJ Denni
081Powershell140227T061807ZVasili S
015k2150609T232545Zkirbyfan
082Python 96 94131017T093050Zgolfer93
080javascript131007T074200ZMath chi
024Perl131006T171209Zmanatwor
070Python 3131006T145326Zasteri
058Haskell140819T173103Zuser344
035J140227T103016Zjpjacobs
153Delphi XE3140227T080142ZTeun Pro
119Java131111T003613ZJustin
nan131104T054341ZJustin
019Befunge98131006T155706ZFireFly
018Perl131203T221306ZF. Hauri
124JavaScript131209T040406ZEliseo D
nan131007T055358Zuser8777
017Golfscript131207T105905ZRees
095JavaScript 104 ES6131007T084502ZFireFly
064PowerShell131204T015740ZIszi
228Game Maker Language131204T213626ZTimtech
055C131007T091521ZRozuur
nan131007T184039ZFabricio
108C#131009T011756ZIgby Lar
042PHP131007T181635ZPleaseSt
011bash131008T105737Zdevnull
033Python131008T002409ZLambda F
016Q131007T213838Zskeevey
018Q131007T153444Ztmartin
066Ruby131007T120802ZKaptajnK
105Javascript131007T074144ZC5H8NNaO
010Shell131007T072914ZFireFly
nan131007T065734Zplannapu
010Perl131006T180229ZGowtham
018Ruby131006T181242ZDoorknob
nanJust for fun131006T144542Zasteri
030J131006T161432ZDan Bron

J-uby, 17 bytes

:upcase|:swapcase

Attempt This Online!

MS-SQL, 83 Bytes

Works on SQL 2017 or above:

SELECT TRANSLATE(v,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')FROM t

The function TRANSLATE() performs individual character replacement, so is the next best thing if I can't use LOWER().

Input is via a pre-existing table t with varchar column v, per our IO rules.

Tried a version that stored the alphabet string and re-used it, but ended up with the exact same 83 byte length:

 DECLARE @ CHAR(26)='abcdefghijklmnopqrstuvwxyz'SELECT TRANSLATE(v,UPPER(@),@)FROM t

AWK, 71 bytes

@load"ordchr";BEGIN{FS=X}{for(;i++<NF;)printf chr(ord(toupper($i))+32)}

Attempt This Online!

Itr, 17 bytes

#µ»ä26¹64+=S32*+«

Reads string (surrounded by quotes) from standard input, prints the result to standard output

online interpreter

Explanation

#             ; read the string from standard input
 µ»   «       ; apply to each element
              ; implicitly print the result

ä             ; duplicate the character
 26¹64+       ; push the range from 65 to 90 ('A' through 'Z')
       =      ; vectorized equality check (of character and range)
        S     ; sum up the vector (1 if the char is in range, 0 otherwise)
         32*+ ; multiply by 32 and add to the character
```

Japt, 7 5 bytes

;dBíC

Try it here

05AB1E, 3 bytes

u.š

Port of @user8777 Python 3 answer.

Try it online.

Explanation:

u    # Convert the (implicit) input to uppercase
 .š  # Switch the case (upper to lower and vice-versa)
     # (and output the result implicitly)

But without any case-altering builtins:

05AB1E, 12 11 6 bytes

žn2ä`‡

-1 byte thanks to @Emigna.
-5 bytes thanks to @TheThonnu

Try it online.

Explanation:

žn      # Push builtin string "ABC...XYZabc...xyz"
  2ä    # Split it into two equal-sized parts: ["ABC...XYZ", "abc...xyz"]
    `   # Pop and push the strings separately to the stack
     ‡  # Transliterate all uppercase letters to lowercase ones
        # (after which the result is output implicitly)

x86-16 machine code, 15 bytes

Assembled:

ac3c 417c 063c 5a7f 020c 20aa e2f2 c3

Unassembled listing:

       _LOOP:
 AC         LODSB            ; load byte from [SI] into AL, advance SI 
 3C 41      CMP  AL, 'A'     ; is char less than 'A'? 
 7C 06      JL   _STORE      ; if so, do not convert 
 3C 5A      CMP  AL, 'Z'     ; is char greater than 'Z'? 
 7F 02      JG   _STORE      ; if so, do not convert 
 0C 20      OR   AL, 'a'-'A' ; lowercase the char 
       _STORE:
 AA         STOSB            ; store char to [DI], advance DI 
 E2 F2      LOOP _LOOP       ; continue loop through string 
 C3         RET              ; return to caller

Callable near function. Input string in DS:[SI], length in CX. Output string in ES:[DI].

Output from PC DOS test program:

enter image description here

JavaScript (Node.js), 53 bytes

s=>s.replace(/[A-Z]/g,x=>parseInt(x,36).toString(36))

Try it online!

From 12Me21's

Vim, 6 bytes

gUUg~~

Or, if allowed,

Vim, 3 bytes

guu

Thunno 2, 2 bytes

RP

Attempt This Online! Port of user8777's Python answer.

Thunno 2, 4 bytes

kAẠṆ

Attempt This Online! No uppercase/swap-case built-ins here.

Thunno 2, 12 bytes

ıDkAsƇ?C32+C

Attempt This Online! No uppercase/swap-case/transliterate built-ins here.

Explanation

RP  # Implicit input
R   # Convert to uppercase
 P  # Swap the case of each character
    # Implicit output
kAẠṆ  # Implicit input
   Ṇ  # Transliterate the input
kA    # (from) the uppercase alphabet
  Ạ   # (to) the lowercase alphabet
      # Implicit output
ıDkAsƇ?C32+C  # Implicit input
ı             # Map over the input string:
 D            #  Duplicate it
    sƇ        #  Pop one copy, and check if it's in
  kA          #  the uppercase alphabet
      ?       #  If it is:
       C      #   Convert to codepoint
        32+   #   Add 32
           C  #   And convert to character
              #  Otherwise, the character stays on top
              # Implicit output, joined

K (ngn/k), 19 17 bytes

{`c$x+32*~"A["'x}

Try it online!

Avoids using the floor builtin (_:).

MATLAB/Octave, 29 bytes

@(x)char(x+32*(x>64).*(x<91))

Try it online!
Output to standard output variable Ans and written to command window.

Acc!!, 44 bytes

N
Count i while _ {
Write _+_/65*90/_*32
N
}

Outputs with a trailing newline. Try it online!

Explanation

The joke's on you, OP: Acc!! doesn't even have built-in to-lower functions... >:^D

N reads a byte from stdin into the accumulator; then we loop while that value is nonzero (i.e. we haven't yet reached end-of-input). We want to add 32 to the character code iff the input is an uppercase letter--that is, if its character code is between 65 and 90. Lacking comparison operators, we use int division:

Code range | _/65 | 90/_ | (_/65)*(90/_)
-----------|------|------|--------------
32-64      | 0    | >0   | 0
65-90      | 1    | 1    | 1
90-126     | >0   | 0    | 0

Now observe that _/65 will always be either 0 or 1 for all values of _ in the range we're interested in. So we can drop the parentheses: _/65*90/_ is equivalent to (_/65*90)/_, which is 90/_ if _ is >= 65 and 0 otherwise. Thus, our conditional lowercase formula is simply _+_/65*90/_*32. We write the corresponding character, read a new one, and loop.

mmo (MMIX executable), 112 bytes (28 tetras)

(jxd)

00000000: 98090100 98010001 00000100 e0002000  Ƭµ¢¡Ƭ¢¡¢¡¡¢¡ṭ¡ ¡
00000010: e3ff0140 00000300 58ff0002 00000000  ẉ”¢@¡¡¤¡X”¡£¡¡¡¡
00000020: 83010000 31ff0140 7502ff20 31ff015b  ³¢¡¡1”¢@u£” 1”¢[
00000030: 7002ff02 c0010102 a3010000 e3ff0140  p£”£Ċ¢¢£ɲ¢¡¡ẉ”¢@
00000040: 00000601 f1fffff3 00000000 20000000  ¡¡©¢ȯ””ṙ¡¡¡¡ ¡¡¡
00000050: 98020008 00000001 980a00ff 00000000  Ƭ£¡®¡¡¡¢Ƭ½¡”¡¡¡¡
00000060: 00000100 980b0000 00000000 980c0001  ¡¡¢¡Ƭ¿¡¡¡¡¡¡Ƭ€¡¢

Disassembly and explanation:

98090100 lop_pre 1,0                (mmo v1, 0 tetras)
98010001 lop_loc 0,1                (start loading at next tetra)
00000100 256                        (which is 256)
E0002000    SETH $0,#2000           (set $0 to address of data segment)
E3FF0140 0H SETL $255,2F            (set $255 to address of handle)
00000300    TRAP 0,Fread,StdIn      (read in one character)
58FF0002    PBNN $0,1F              (skip next instr if not EOF)
00000000    TRAP 0,Halt,0           (quit)
83010000 1H LDBU $1,$0,0            (read that byte in)
31FF0140    CMP  $255,$1,'@'        (compare with '@')
7502FF20    ZSP  $2,$255,#20        (if greater, then set $2 to 0x20)
31FF015B    CMP  $255,$1,'['        (compare with '[')
7002FF02    ZSN  $2,$255,$2         (unless less, clear $2)
C0010102    OR   $1,$1,$2           (or in $2)
A3010000    STBU $1,$0,0            (store it back)
E3FF0140    SETL $255,2F            (set $255 to address of handle)
00000601    TRAP 0,Fwrite,StdOut    (write that byte out)
F1FFFFF3    JMP  0B                 (loop back)
00000000                            (padding for alignment)
20000000 2H OCTA Data_Segment,1     (the handle)
98020008 lop_skip 8                 (slightly cheaper than two zero tetras)
00000001                            (end of handle)
980A00FF lop_post 255               (postamble, rG = 255)
00000000
00000100                            (start execution at location 256)
980B0000 lop_stab                   (begin symbol table)
00000000                            (no symbols)
980C0001 lop_end 1                  (symtab is one tetra long)

C (gcc), 61 59 bytes

-2 thanks to @ceilingcat

main(i){while(i=getchar()-10)putchar(i+(i>54&i<81?42:10));}

Try it online!

Ungolfed:

int main(i){
    while((i=getchar()) != '\n') {
        if(i>64&i<91){ // uppercase ASCII range is 65-92
            putchar(i+32); // lowercase ASCII range is 97-122
        } else {
            putchar(i);
        }
    }
}

batch 112 bytes

lower.bat

@Set "s=%~1"&@for %%c in (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)do @Set "s=!s:%%c=%%c!"
@Echo(!s!

Notes:

///, 113 bytes

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

Try it online!

Simply replaces all the uppercase characters with lowercase. Because there's no other way to take input in ///, it is hardcoded:

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

Julia, 28 bytes

x->map(c->c+32('@'<c<'['),x)

Try it online!

Vyxal, 2 bytes

⇧N

Try it Online!

This is the same as the 05ab1e answer but shorter because overloads.

Non-trivial version

kAkaĿ

Try it Online!

Funnily enough, I've used this before.

kAka    # Push "ABC...XYZ" and "abc...xyz"
    Ŀ   # Transliterate input with the above strings

naz, 92 90 bytes

2x1v8a8m2x2v2d3m5s2x3v1x1f1r3x1v4e3x2v2g1o1f0x1x2f3x3v3l1o1f0x1x3f8a8a8a8a1o1f0x1x4f0a0x1f

Works for any null-terminated input string.

Try it online!

Explanation (with 0x instructions removed)

2x1v                   # Set variable 1 equal to 0
8a8m2x2v               # Set variable 2 equal to 64 ("@")
2d3m5s2x3v             # Set variable 3 equal to 91 ("[")
1x1f1r3x1v4e3x2v2g1o1f # Function 1
                       # Read a byte of input
                       # Goto function 4 if it equals variable 1
                       # Goto function 2 if it's greater than variable 2
                       # Otherwise, output it and call the function again
1x2f3x3v3l1o1f         # Function 2
                       # Goto function 3 if the register is less than variable 3
                       # Otherwise, output and jump to function 1
1x3f8a8a8a8a1o1f       # Function 3
                       # Add 32 to the register, output, and call function 1
1x4f0a                 # Function 4
                       # Add 0 to the register
1f                     # Call function 1

FALSE, 29 bytes

[^$1_=~][$$64>\91>~&[32+]?,]#

Try it online!

J, 39 30 bytes

(<&91*64&<)`(,:32+])}&.(a.i.])

-9 thanks to xash

Try it online!

Uses Item Amend } to choose which characters need to be lowercased and which passed through unaltered.

It applies this operation "under" conversion to ascii indexes &.(a.i.]) -- it first converts the string to the indexes of its characters, than applies the item amend transformation, then converts back.

The item amend transformation is defined by the gerund (<&91*64&<)`(,:32+]). (,:32+]) defines the two possibilities: the input unaltered, or the the input shifted 32 places to the right, converting A to a, etc. (<&91*64&<) determines which integers go into which transformation category: If an integer is greater than 64 and less than 91 -- ie, the integers corresponding to ABCDEFGHIJKLMNOPQRSTUVWXYZ -- it gets shifted by 32.

Python 3, 48

input().translate({c:c|32for c in range(65,91)})

PowerShell, 53 49 43 bytes

-4 bytes thanks @AdmBorkBork

-6 bytes thanks @Veskah

-join($args|%{[char](32*($_-in65..90)+$_)})

Try it online!

JavaScript(ES6), 92/90 bytes

prompt().split('').map(x=>String.fromCharCode((y=x.charCodeAt(),y>64&y<91)?y+32:y)).join('')
l=a=>a.split('').map(x=>String.fromCharCode((y=x.charCodeAt(),y>64&y<91)?y+32:y)).join('')

Turn the input string into a char array, turn all uppercase letters into lowercase, and turn it back into a string.(Difference between uppercase letter and lowercase letter('a'-'A') is 32, 64 is '@', 91 is '['.)

If using alerts is required, that increases the characters by 7, which means it's 99 bytes.

><>, 17 bytes

i::" @["{)${(**+o

Try it online!

Forth (gforth), 55 bytes

: f 0 do dup i + c@ dup 65 91 within 32 * - emit loop ;

Try it online!

Explanation

Iterates through the string, for each character:

Code Explanation

: f                   \ start new word definition
  0 do                \ start counted loop from 0 to string-length - 1
    dup i +           \ duplicate the string address and add the loop index
    c@                \ get the ascii char value at that address
    dup 65 91 within  \ check if value is between 65 and 90 (-1 = true, 0 = false)
    32 * -            \ multiply result by 32 and subtract from original number
    emit              \ output value
  loop                \ end loop
;                     \ end word definition

JavaScript, 58 bytes

s=>s.replace(/[A-Z]/g,x=>(x.charCodeAt()-55).toString(36))

q 37 bytes

{$[x in .Q.A;x:(.Q.A!.Q.a)[x];x]}each

Explanation

$[x in .Q.A          // If the character is in the capitals list
  x:(.Q.A!.Q.a)[x]   // Create a key mapping between upper and lower case letters,
                     // and set x to it's pair
  x]}                // else, just return the character
  each               // apply to each character in string passed in

Example

q){$[x in .Q.A;x:(.Q.A!.Q.a)[x];x]}each "LoWersWFSfdgSA"
"lowerswfsfdgsa"

Python 3, 78 bytes

t=input()
for c in t:
 x=ord(c)
 if 64<x<91:t=t.replace(c,chr(x+32))
print(t)

Perl, 9 + 1 (for -p flag) = 10

$_="\L$_"

\L was specifically asked about and allowed, because even though it's a built-in, it's not a function.

Powershell - 81 characters

Program:

param($s);[char[]]$s|%{if($_-lt90-and$_-gt64){$n+=[char](+$_+32)}else{$n+=$_}};$n

Example Usage:

.\lower.ps1 -s "TEST!"

Output:

test!

How it works:

It just adds 32 to the decimal value of the ASCII character, which is the lowercase version.
It only does this if it is within 64-90, which is all capital letters.

k2, 15 bytes

I am super late to this one, but I found this cool anyway.

{_ci 32+_ic x}'

Also:

Pyth, 10 bytes

Doesn't really count because Pyth was created after this was posted. Still cool.

jkmC+32Cdw

Python - 96 94 82

for c in input():print(chr(ord(c)-65+97),end="")if c.isupper()else print(c,end="")

Ungolfed version:

for char in input():
    print(chr(ord(char) - (ord("A") - ord("a"))), end="") if char.isupper() \
    else print(char, end="")

javascript 80

"X".replace(/[A-Z]/g,function($){return String.fromCharCode($.charCodeAt()+32)})

(76 if you remove "X")

with prompt and alert - 92

alert(prompt().replace(/[A-Z]/g,function($){return String.fromCharCode($.charCodeAt()+32)}))

fiddle

thanks to @FireFly @some @C5H8NNaO4 and @minitech

Perl: 24 characters

s/[A-Z]/chr 32+ord$&/ge

Sample run:

bash-4.1$ perl -pe 's/[A-Z]/chr 32+ord$&/ge' <<< 'Hello @ WORLD !'
hello @ world !

Python 3 - 70

Updated for OP's changes.

I'm a Python newbie, so any critique is welcome.

print("".join(chr(ord(c)+32) if 64<ord(c)<91 else c for c in input()))

Haskell - 58

p x|(elem x['A'..'Z'])=[x..]!!32|1<2=x
main=interact$map p

J 35

echo(+32*64&<*.95&>)&.(a.&i.)1!:1]3

Using the magical under &.. This looks up the ascii code, then adds 32 * the boolean inRange , where inRange is x>64 and x<91. The under operation automatically applies the inverse lookup afterwards, resulting in the wanted lowercase.

In action:

   echo(+32*64&<*.91&>)&.(a.&i.)1!:1]3
Hello World AZ!
hello world az!

Delphi XE3 (153 chars)

uses System.SysUtils;var u:string;i:int8;begin readln(u);for i:=1to Length(u)do if CharInSet(u[i],['A'..'Z'])then u[i]:=Chr(Ord(u[i])+32);writeln(u);end.

Not a winner but fun to do :)

with indent

uses
  System.SysUtils;
var
  u:string;
  i:int8;
begin
  readln(u);
  for i:=1to Length(u)do
    if CharInSet(u[i],['A'..'Z'])then
      u[i]:=Chr(Ord(u[i])+32);
    writeln(u);
end.

Java - 119

class a{static{for(char c:(new java.util.Scanner(System.in)).nextLine().toCharArray())System.out.print((char)(c|32));}}

Works for every character except @ which becomes the back-tick (`), and the following (foo:bar for foo becomes bar) :

\:|
]:}
^:~
_:

Even though this isn't a true solution because it has 5 cases where it doesn't work, I thought it was very interesting. It takes the characters of the input and does a bitwise or with ' ' (c|32).

I discovered that c^32 swaps the case when the input is only letters while solving a project euler problem. I wondered what would happen in I changed the XOR to an OR.

Because I felt like it (I know that I'm a bit late)

Java - 162

class a{public static void main(String[]a){for(char c:(new java.util.Scanner(System.in)).nextLine().toCharArray())System.out.print((char)((c>64&&c<91)?c+32:c));}}

expanded:

public class a{
    public static void main(String[] a) {
        for (char c : (new java.util.Scanner(System.in)).nextLine().toCharArray()) {
            System.out.print((char) ((c > 64 && c < 91) ? c + 32 : c));
        }
    }
}

Befunge-98 - 26 22 21 19

~:''-d2*/1-!' *+,#@

Relies on the fact that (c-39)/26 is 1 only for character codes of uppercase ASCII characters (assuming integer division). For each character c, print out c + (((c-39)/26)==1)*' '.

Sample session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Perl 18

s/[A-Z]/$&|" "/eg

Something like:

perl -pe 's/[A-Z]/$&|" "/eg'  <<<'are NOT allowed to: ToLower() in .NET, strtolower() in PHP'
are not allowed to: tolower() in .net, strtolower() in php

and

perl -pe 's/[A-Z]/$&|" "/eg' <<< "The input string Doesn't cOntaIn...( C0D3-@01F. ;-)"
the input string doesn't contain...( c0d3-@01f. ;-)

For @FireFly :

perl -pe 's/[A-Z]/$&|" "/eg' <<< "Doesn't this translate @ to \` and [\]^_ to {|}~DEL? "
doesn't ... @ to ` and [\]^_ to {|}~del? 

no.

More generic: 18 chars anyway:

s/[A-Z]/$&|" "/eg

s/[A-Z]/$&^" "/eg

This wont change anything in state:

perl -pe 's/[A-Z]/$&^" "/eg' <<< "Doesn't ... @ to \` and [\]^_ to {|}~DEL? "
doesn't ... @ to ` and [\]^_ to {|}~del? 

All work fine, but the advantage of changing | (or) by ^ (xor) is that the same syntax could be used for toLower, toUpper or swapCase:

toUpper:

perl -pe 's/[a-z]/$&^" "/eg' <<< "Doesn't ... @ to \` and [\]^_ to {|}~DEL? "
DOESN'T ... @ TO ` AND [\]^_ TO {|}~DEL? 

and swapCase (18+1 = 19 chars):

perl -pe 's/[a-z]/$&^" "/egi' <<< "Doesn't ... @ to \` and [\]^_ to {|}~DEL? "
dOESN'T ... @ TO ` AND [\]^_ TO {|}~del? 

JavaScript 124

The closest I got was 124 characters...

b=prompt();a=[];for(c=b.length;c--;)a[c]="@"<b[c]&"[">b[c]?String.fromCharCode(b[c].charCodeAt(0)+32):b[c];alert(a.join(""))

@Firefly, nice work with using the "map" command... I've yet to master it...

Python 2.7 - 30 (with terrible and unapologetic rule abuse)

raw_input().upper().swapcase()

As an anonymous edit pointed out, you can do it in 27 26 in Python 3:

input().upper().swapcase()

I'm flagrantly abusing the rules here, but...

Important: you are NOT allowed to use a built-in function that converts the string (or just one character) to lowercase (such as ToLower() in .NET, strtolower() in PHP , ...)! You're allowed to use all other built-in functions, however.

This takes the strings and coverts it to upper case. Then in a very unrelated method call, it reverses the case of the string - so that any lower case letters become upper case letters... and swaps any upper case letters to lower case letters.

Golfscript - 17

Program:

{..64>\91<*32*+}%

Explanation:

  1. {}% maps the code inside to every character in string.
  2. .. copies the top of the stack (the character) twice.
  3. 64> 1 if character code is greater than 64, else 0.
  4. \ swaps the two items on the stack (gets the second copy of the letter, and stores the result of 64> in position two).
  5. 91< checks to see if character code is less than 91. Similar to step 3.
  6. * multiplies the results from steps 3 and 5 together. Only equal to 1, if both steps were true.
  7. 32* multiplies the result of step 6 with 32. Will be 32 if step 6 was 1, else 0.
  8. + add the result (either 32 or 0) onto the character code.

Example output:

echo HelLO @ WorLD | ruby golfscript.rb upper_to_lower.gs
hello @ world

JavaScript - 109 104 (ES6: 95)

Thanks to some for the corrected version.

a=prompt();for(b=[i=0];c=a.charCodeAt(i);)b[i++]=String.fromCharCode(c|(c>64&c<91)*32);alert(b.join(""))

The following works if the browser supports ES6 function expressions:

alert(prompt().split("").map(c=>String.fromCharCode(c.charCodeAt()|(c>"@"&c<"[")*32)).join(""))

PowerShell: 69 65 64

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](32+[char]"$args")})

Changes from original:

  • Rearranged last argument so that [int] is no longer needed, per suggestion in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

32+ converts the character to an integer, representing the ASCII code, and increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

Game Maker Language, 228

Make script/function s with this code, 53 characters:

a=argument0;b=string_replace_all(b,string_upper(a),a)

Then, use this 175 character code:

b=get_string('','')s('a')s('b')s('c')s('d')s('e')s('f')s('g')s('h')s('i')s('j')s('k')s('l')s('m')s('n')s('o')s('p')s('q')s('r')s('s')s('t')s('u')s('v')s('w')s('x')s('y')s('z')

The input (stored in variable b), is now lowercase.

C 64 63 59 55 chars

main(c){while(c=getchar(),~c)putchar(c-65u<27?c+32:c);}

DELPHI

const
  UpChars:set of AnsiChar = ['A'..'Z'];
var
  I: Integer;
begin
  SetLength(Result, Length(pString));
  for I := 1 to length(pstring) do
    Result[i] := AnsiChar((Integer(pString[i] in UpChars))*(Ord(pString[i])+32));
  WriteLn(Result);
end;

C# - 108

class P{static void Main(string[]a){foreach(var c in a[0])System.Console.Write(
(char)(c>64&&c<91?c+32:c));}}

About 70 for just the method body.

Add 5 chars to include a LF/CR in the output:

class P{static void Main(string[]a){foreach(var c in a[0]+"\n")System.Console.Write(
(char)(c>64&&c<91?c+32:c));}}

A LINQ version would be shorter:

class P{static void Main(string[]a){a[0].Any(c=>System.Console.Write(
(char)(c>64&&c<91?32+c:c))is P);}}

(103) .. except that it requires using System.Linq; (total: 121).

PHP (42)

Run from the command line:

-R'echo@str_ireplace($a=range(a,z),$a,$argn);'

-R and the single quotes are not counted.

bash: 11 characters?

$ i="This is A STRING"
$ echo ${i,,}
this is a string

Python (33)

If in doubt, use the shell.

import os;os.system('tr A-Z a-z')

Regrettably, this is still longer than Lego's solution.

Q (16)

.......

{x^(.Q.A!.Q.a)x}

Q, 18

.....

{x^ssr/[x]..Q`a`A}

Ruby: 66

def l(s)s.bytes.map{|b|(65..90).include?(b)?b+32:b}.pack('c*');end

Javascript, 105

prompt().split("").map(function(a){c=a.charCodeAt(0);return String.fromCharCode(c|(c-64?32:0))}).join("")

Actually ther was no output form specified, so run it in console Yea, JavaScript really is verbose with charcode <-> string

Shell - 10

Translation of @Gowtham's Perl solution using /bin/tr.

tr A-Z a-z

Sample run:

% tr A-Z a-z <<<'Hello WORLD! @'
hello world! @

R

71 characters:

chartr(paste(LETTERS,collapse=""),paste(letters,collapse=""),scan(,""))

83 characters:

a=as.integer(charToRaw(scan(,"")))
b=a%in%(65:90)
a[b]=a[b]+32
rawToChar(as.raw(a))

Perl - 11 10 characters.

y/A-Z/a-z/

y/// is same as tr///!

In action:

% perl -pe 'y/A-Z/a-z/' <<< 'Hello @ WORLD !'
hello @ world !

Ruby, 18 characters

Nothing really interesting.

gets.tr'A-Z','a-z'

(run in IRB)

Just for fun: a confusing version:

$,=$* *' ';$;=$,.tr'A-Z','a-z';$><<$;

Run like this:

c:\a\ruby>lowercase.rb Llamas are AMAZING!

Output

llamas are amazing!

Just for fun, because Java's my language.

Java - 162 175

Fixed for OP's updates.

class a{public static void main(String[]a){String b="";for(char c:new java.util.Scanner(
System.in).nextLine().toCharArray())b+=c>64&&c<91?(char)(c+32):c;System.out.print(b);}}

With line breaks and tabs

class a{

    public static void main(String[]a){
        String b="";
        for(char c:new java.util.Scanner(System.in).nextLine().toCharArray())b+=c>64&&c<91?(char)(c+32):c;
        System.out.print(b);
    }

}

J - 30

'@Z'(]+32*1=I.)&.(a.&i.)1!:1]1

J is read right-to-left, so to break this down:

  1. Prompt user for input: 1!:1]1
  2. Perform algorithm in code-point-space: &.(a.&i.)
  3. Identify character range for each letter; the characters between codepoints "@" and "Z" are considered uppercase: 1=I..
  4. For each uppercase codepoint, add 32: ]+32* ...
  5. Note that step (2) creates an implicit step (5): we started out by projecting from character to integer domain, so now that we're finished, we map those integers back onto characters.

Obviously this particular implementation only considers ASCII; but the approach could be extended to at least the basic multilingual plane in Unicode.