Class String (namespace Nette)


String tools library.


Copyright: Copyright (c) 2004, 2010 David Grudl
Located: in /String.php (line 21)
Public Method Summary
String
Static class - cannot be instantiated.
static string
capitalize (string $s)
Capitalize string.
static bool
checkEncoding (string $s, [string $encoding = 'UTF-8'])
Checks if the string is valid for the specified encoding.
static string
chr (int $code, [string $encoding = 'UTF-8'])
Returns a specific character.
static bool
endsWith (string $haystack, string $needle)
Ends the $haystack string with the suffix $needle?
static string
fixEncoding (string $s, [string $encoding = 'UTF-8'])
Returns correctly encoded string.
static string
indent (string $s, [int $level = 1], [string $chars = "\t"])
Indents the content from the left.
static string
lower (string $s)
Convert to lower case.
static string
normalize (string $s)
Removes special controls characters and normalizes line endings and spaces.
static string
padLeft (string $s, int $length, [string $pad = ' '])
Pad a string to a certain length with another string.
static string
padRight (string $s, int $length, [string $pad = ' '])
Pad a string to a certain length with another string.
static bool
startsWith (string $haystack, string $needle)
Starts the $haystack string with the prefix $needle?
static string
trim (string $s, [string $charlist = " \t\n\r\0\x0B\xC2\xA0"])
Strips whitespace.
static string
truncate (string $s, int $maxLen, [string $append = "\xE2\x80\xA6"])
Truncates string to maximal length.
static string
upper (string $s)
Convert to upper case.
static string
webalize (string $s, [string $charlist = NULL], [bool $lower = TRUE])
Converts to web safe characters [a-z0-9-] text.

Method Details

line 27

__construct

public String __construct ()

Static class - cannot be instantiated.

Output
String  

line 221

capitalize

public static string capitalize (string $s)

Capitalize string.

Input
string $s UTF-8 encoding
Output
string  

line 40

checkEncoding

public static bool checkEncoding (string $s, [string $encoding = 'UTF-8'])

Checks if the string is valid for the specified encoding.

Input
string $s byte stream to check
string $encoding expected encoding
Output
bool  

line 67

chr

public static string chr (int $code, [string $encoding = 'UTF-8'])

Returns a specific character.

Input
int $code codepoint
string $encoding encoding
Output
string  

line 93

endsWith

public static bool endsWith (string $haystack, string $needle)

Ends the $haystack string with the suffix $needle?

Input
string $haystack
string $needle
Output
bool  

line 53

fixEncoding

public static string fixEncoding (string $s, [string $encoding = 'UTF-8'])

Returns correctly encoded string.

Input
string $s byte stream to fix
string $encoding encoding
Output
string  

line 185

indent

public static string indent (string $s, [int $level = 1], [string $chars = "\t"])

Indents the content from the left.

Input
string $s UTF-8 encoding or 8-bit
int $level
string $chars
Output
string  

line 197

lower

public static string lower (string $s)

Convert to lower case.

Input
string $s UTF-8 encoding
Output
string  

line 105

normalize

public static string normalize (string $s)

Removes special controls characters and normalizes line endings and spaces.

Input
string $s UTF-8 encoding or 8-bit
Output
string  

line 249

padLeft

public static string padLeft (string $s, int $length, [string $pad = ' '])

Pad a string to a certain length with another string.

Input
string $s UTF-8 encoding
int $length
string $pad
Output
string  

line 265

padRight

public static string padRight (string $s, int $length, [string $pad = ' '])

Pad a string to a certain length with another string.

Input
string $s UTF-8 encoding
int $length
string $pad
Output
string  

line 80

startsWith

public static bool startsWith (string $haystack, string $needle)

Starts the $haystack string with the prefix $needle?

Input
string $haystack
string $needle
Output
bool  

line 234

trim

public static string trim (string $s, [string $charlist = " \t\n\r\0\x0B\xC2\xA0"])

Strips whitespace.

Input
string $s UTF-8 encoding
string $charlist
Output
string  

line 159

truncate

public static string truncate (string $s, int $maxLen, [string $append = "\xE2\x80\xA6"])

Truncates string to maximal length.

Input
string $s UTF-8 encoding
int $maxLen
string $append UTF-8 encoding
Output
string  

line 209

upper

public static string upper (string $s)

Convert to upper case.

Input
string $s UTF-8 encoding
Output
string  

line 132

webalize

public static string webalize (string $s, [string $charlist = NULL], [bool $lower = TRUE])

Converts to web safe characters [a-z0-9-] text.

Input
string $s UTF-8 encoding
string $charlist ASCII
bool $lower
Output
string