Class String (namespace Nette)


String tools library.


Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /String.php (line 30)
Public Method Summary
String
Static class - cannot be instantiated.
static void
bytes ($bytes)
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 bool
startsWith (string $haystack, string $needle)
Starts the $haystack string with the prefix $needle?
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])
Converts to web safe characters [a-z0-9-] text.

Method Details

line 36

__construct

public String __construct ()

Static class - cannot be instantiated.

Output
String  

line 239

bytes

public static void bytes ($bytes)

Input
$bytes
Output
void  
Tags
Deprecated

line 229

capitalize

public static string capitalize (string $s)

Capitalize string.

Input
string $s UTF-8 encoding
Output
string  

line 49

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 76

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 102

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 62

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 193

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 205

lower

public static string lower (string $s)

Convert to lower case.

Input
string $s UTF-8 encoding
Output
string  

line 114

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 89

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 167

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 217

upper

public static string upper (string $s)

Convert to upper case.

Input
string $s UTF-8 encoding
Output
string  

line 140

webalize

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

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

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