Strings (funtions)

Strings = {}
Strings.EndsWith     = StringEndsWith
Strings.StartsWith   = StringStartsWith
Strings.StripUnicode = StringStripUnicode
Strings.Truncate     = StringTruncate

Ends with

Strings.EndsWith( string, suffix )

function StringEndsWith( string, suffix )
{
	var n = string.length;
	var s = suffix.length;
	var i = string.indexOf( suffix );

	return (i == (n - s));
}

Starts with

Strings.StartsWith( string, prefix )

function StringStartsWith( string, prefix )
{
    return (0 === string.indexOf( prefix ));
}

Strip unicode

Strings.StripUnicode( string )

function StringStripUnicode( s )
{
	var r = "";
	var l = "";
	var n = s.length;
	
	for ( var i=0; i < n; i++ )
	{
		try {
			if ( s.charCodeAt( i ) <= 255 )
			{
				r += s.charAt( i );
				l += "#";
			}
			else
			{
				l += "U";
			}
		}
		catch (err)
		{}
	}
	
	console.log( l );
	
	return r;
}

Truncate

Strings.Truncate( string, prefix )

function StringTruncate( text, max_length )
{
	if ( text && (text.length > max_length) )
	{
		text = text.substring( 0, max_length - 3 ) + "...";
	}
	return text;
}