String To Lower Case

From SwiftAPI

Jump to: navigation, search

Contents

C

MSDN

int tolower( int c );
char a[] = "HELLO world";
int len = strlen(a);
for(int i = 0; i < len; i++) {
    a[i] = tolower(a[i]);
}
// a == "hello world"

C++

#include <cctype>
#include <algorithm>
#include <string>
using namespace std;
 
string a = "HELLO world";
transform(a.begin(), a.end(), a.begin(), (int(*)(int))tolower);
// a == "hello world"

C#

MSDN

System.String : public string ToLower()
string a = "HELLO world";
string b = a.ToLower();
// b == "hello world"

Java

J2SE 1.4.2

java.lang.String : public String toLowerCase()
String a = "HELLO world";
String b = a.toLowerCase();
// b == "hello world"

JavaScript

Mozilla MSDN

var a = "HELLO world";
var b = a.toLowerCase();
// b == "hello world"

Objective-C

developer.apple.com

@property(readonly, copy) NSString *lowercaseString
NSString *a = @"HELLO world";
NSString *b = a.lowercaseString;
// b == "hello world"

Perl

perldoc

lc EXPR
$a = "HELLO world";
$b = lc($a);
# $b == "hello world"

PHP

php.net

string strtolower ( string $str )
$a = "HELLO world";
$b = strtolower($a);
// $b == "hello world"

Python

docs.python.org

str.lower()
a = "HELLO world"
b = a.lower()
# b == "hello world"

Ruby

Ruby-Doc.org

str.downcase => new_str
a = "HELLO world"
b = a.downcase
# b == "hello world"
 
# Or modify the instance directly
a = "HELLO world"
a.downcase!
# a == "hello world"

Swift

import Foundation
 
let a = "HELLO world"
let b = a.lowercaseString
// b == "hello world"

Visual Basic .NET

MSDN

System.String : Public Function ToLower As String
Dim a As String = "HELLO world"
Dim b As String
b = a.ToLower()
' b == "hello world"
Personal tools