[Question]
  [
The goal of this code-golf is to create a code that lets the user input an ASCII string (contains only [printable ASCII characters](https://en.wikipedia.org/wiki/ASCII#Printable_characters)), and your program outputs the lower-case variant of this string.
**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.
**Another important note:** The input string doesn't contain *only* uppercase characters. The input string is a mix of uppercase characters, lowercase characters, numbers and other [ASCII printable](https://en.wikipedia.org/wiki/ASCII#Printable_characters) characters.
Good luck!
  
[Answer]
# 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**.
[Answer]
**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 !
```
[Answer]
### 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! @
```
[Answer]
## 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 @[`{
```
[Answer]
### Python 3, 48
```
input().translate({c:c|32for c in range(65,91)})
```
[Answer]
## 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!
```
[Answer]
## 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.
[Answer]
**C 64 63 59 55 chars**
```
main(c){while(c=getchar(),~c)putchar(c-65u<27?c+32:c);}
```
[Answer]
**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
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 3 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
u.š
```
Port of [*@user8777* Python 3 answer](https://codegolf.stackexchange.com/a/12774/52210).
[Try it online.](https://tio.run/##yy9OTMpM/f@/VO/owv//QzIyixU8ixUcFYIS81LycxVCUotLFJQNFQE)
**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](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~12~~ ~~11~~ 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
žn2ä`‡
```
-1 byte thanks to *@Emigna*.  
-5 bytes thanks to *@TheThonnu*
[Try it online.](https://tio.run/##yy9OTMpM/f//6L48o8NLEh41LPz/3yM1JydfRyE8vygnRREA)
**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)
```
[Answer]
# 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 !
```
[Answer]
**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;
```
[Answer]
### 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(""))
```
[Answer]
### 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](https://codegolf.stackexchange.com/posts/comments/29281) :
```
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? 
```
[Answer]
## 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](http://jsfiddle.net/mendelthecoder/mhLXe/)
thanks to @FireFly @some @C5H8NNaO4 and @minitech
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~19~~ 17 bytes
```
{`c$x+32*~"A["'x}
```
[Try it online!](https://ngn.codeberg.page/k#eJxLs6pOSFap0DY20qpTcoxWUq+o5eJKU1DySM3JyddRCM8vyklRVAIA1kgK9g==)
Avoids using the `floor` builtin (`_:`).
* `~"A["'` generate a bit mask with 1's in the positions in the input containing uppercase letters
* `32*` multiply by 32, which calculates the offsets between uppercase and lowercase ASCII character codes
* `x+` add the offsets to the input (converting the string input to integers)
* ``c$` convert back to characters
[Answer]
# 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](https://i.stack.imgur.com/XZRQ3.png)](https://i.stack.imgur.com/XZRQ3.png)
[Answer]
## 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))
```
[Answer]
# Q, 18
.....
```
{x^ssr/[x]..Q`a`A}
```
[Answer]
# Q (16)
.......
```
{x^(.Q.A!.Q.a)x}
```
[Answer]
# 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.
[Answer]
## 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.
[Answer]
## 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](https://i.stack.imgur.com/QTd2k.jpg)
(Current version tested - screenshot not yet posted.)
[Answer]
# 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
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~53~~ ~~49~~ 43 bytes
*-4 bytes thanks @AdmBorkBork*
*-6 bytes thanks @Veskah*
```
-join($args|%{[char](32*($_-in65..90)+$_)})
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfmvkmZb/V83Kz8zT0MlsSi9uEa1Ojo5I7EoVsPYSEtDJV43M8/MVE/P0kBTWyVes1bzfy2XSoWCrYKSh6uPj79CeH5RToqigmeJQmaxgqeOQgDI5GCQyQrupZWKSlxqKmkKDhVcEE0Qe9Qd1fX01KPUtdUTQYwqdU2oqv8A "PowerShell – Try It Online")
[Answer]
## Vim, 6 bytes
`gUUg~~`
Or, if allowed,
## Vim, 3 bytes
`guu`
[Answer]
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);
    }
}
```
[Answer]
# 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
[Answer]
Ruby: 66
```
def l(s)s.bytes.map{|b|(65..90).include?(b)?b+32:b}.pack('c*');end
```
[Answer]
## 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).
]