String To Upper Case

From SwiftAPI

Jump to: navigation, search

Contents

C

msdn

int toupper( int c );
char a[] = "HELLO world";
int len = strlen(a);
for(int i = 0; i < len; i++) {
	a[i] = toupper(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))toupper);
// a == "HELLO WORLD"

C#

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

Java

J2SE 1.4.2

java.lang.String : public String toUpperCase()
string a = "HELLO world";
string b = a.toUpperCase();
// b == "HELLO WORLD"

JavaScript

Mozilla

var a = "HELLO world";
var b = a.toUpperCase();
// b == "HELLO WORLD"

Objective-C

developer.apple.com

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

Perl

perldoc

uc EXPR
$a = "HELLO world";
$b = uc($a);
# $b == "HELLO WORLD"

PHP

php.net

string strtoupper ( string $str )
$a = "HELLO world";
$b = strtoupper($a);
// $b == "HELLO WORLD"

Python

docs.python.org

str.upper()
a = "HELLO world"
b = a.upper()
# b == "HELLO WORLD"

Ruby

ruby-doc.org

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

Swift

import Foundation
 
let a = "HELLO world"
let b = a.uppercaseString
// b == "HELLO WORLD"

Visual Basic .NET

MSDN

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