Download Latest Version zString.zip (230.6 kB)
Email in envelope

Get an email when there's a new version of Yet another String Library

Home / v1.2
Name Modified Size InfoDownloads / Week
Parent folder
Readme 2011-11-01 2.9 kB
zString.zip 2011-11-01 230.3 kB
Totals: 2 Items   233.2 kB 0
Package:	zString (Yet Another String Library)
Author:		Keshav Channa
Version:	1.0
Date:		31-05-2011
License:	The MIT License (MIT)  (free to use in commercial applications also)
Credits:	Would be much appreciated :)


=====================================================
What is it?
=====================================================
A string library (yet another one????)

But with some added benefits:

* Completely independent library. 
	- Means, you don't need to include any unnecessary code.
* Error values returned from functions, rather than throwing exceptions.
	- Personally, I don't want to put a exception handler code for string operations.
* Has copy-on-write mechanism.
	- Means, assignment is almost free.
* Has basic support for C# style type-safe string formatting. (I'll try to keep updating this feature)
	- Means, it's easier to format strings and
	- No more crashes, because you passed a wrong parameter.
	- See below for some examples
* Also supports the legacy printf style string formatting.
* Support for directory and filename functions.


=====================================================
Platforms
=====================================================
Written with cross-platform compatibility in mind.
But currently tested only for Windows platform.


=====================================================
Type Safe String Format 
=====================================================
The "Type Safe String Format" code is inspired from an article on CodeProject by Ivo Beltchev.
http://www.codeproject.com/KB/string/FormatString.aspx



=====================================================
Example: C# style type safe string formatting 

You can have a look at the test cases for more formatting options.
=====================================================

Input: FormatString("Int: {0}", 12345) ;	// index with no custom formatting
Output: Int: 12345

Input: FormatString("Int: {0 }a", 12345) ;	// spaces within {} are ignored
Output: Int: 12345a

Input: FormatString("Int: {0:}", 12345) ;
Output: Int: 12345

Input: FormatString("Int: {0:d0}", 12345) ;
Output: Int: 12345

Input: FormatString("Int: {0:}->33here", 12345) ;
Output: Int: 12345->33here

Input: FormatString("Int: {0:d}->22here", 12345) ;
Output: Int: 12345->22here

Input: FormatString("Int: {0:d8}->here", 12345) ;	// Prefixes '0'
Output: Int: 00012345->here

Input: FormatString("Int: {0,-10:d}Here", 12345) ;	// Suffixes space
Output: Int: 12345     Here

Input: FormatString("Int: {0,8:d}What??", 12345) ;	// Prefixes space
Output: Int:    12345What??



=====================================================
Directory and Filename helpers
=====================================================
Directory and Filename handling is very useful.
This string library comes with in-built helpers for Directory and Filename handling.
I'll keep extending this area as and when I can.
Source: Readme, updated 2011-11-01