is a collection of non-MFC and non-STL string
functions I have been using for many years. They are all modelled on
functions available in standard C runtime (CRT), so they are fairly
While there might be better or more efficient alternatives to some of
these functions available via STL or boost, in the real world I am
frequently constrained to use what my clients want. In some cases, they
do not want the integration, support, and QA problems
associated with introducing new technology into legacy applications.
Hence, being able to show them string functions that "look like" the CRT,
but without any STL, is often deciding point, and greatly simplifies
The included demo app performs some basic tests, and also shows how
XString functions are used:
- _tcscrep() - Replace character in a string (case sensitive)
- _tcsicrep() - Replace character in a string (case insensitive)
- _tcsicrem() - Remove character in a string (case insensitive)
- _tcscrem() - Remove character in a string (case sensitive)
- _tcsistrrem() - Remove substring in a string (case insensitive)
- _tcsstrrem() - Remove substring in a string (case sensitive)
- _tcsistr() - Find a substring in a string (case insensitive)
- _tcsistrrep() - Replace one substring in a string with another substring (case insensitive)
- _tcstrim() - Removes (trims) leading and trailing whitespace characters from a string
- _tcsrtrim() - Removes (trims) trailing whitespace characters from a string
- _tcsltrim() - Removes (trims) leading whitespace characters from a string
- _tcszdup() - Allocates buffer with new, fills it with zeros, copies string
- _tcsnzdup() - Allocates buffer with new, fills it with zeros, copies count
characters from string to buffer
- _tcsccnt() - Count number of occurrences of a character in a string
How To Use
To integrate XString functions into your app, you first need
to add following files to your project:
If you include XString in project that uses precompiled headers,
you must change C/C++ Precompiled Headers settings to
Not using precompiled headers for XString.cpp.
Next, include the header file XString.h in
appropriate project files.
Now you are ready to start using XString.
Please see XStringTest.cpp for examples.
Version 1.1 — 2007 August 7
- Added _tcszdup()
- Added _tcszndup()
- Added _tcsccnt()
Version 1.0 — 2007 June 25
This software is released into the public domain. You are free to
use it in any way you like, except that you may not sell this source code.
If you modify it or extend it, please to consider posting new code here
for everyone to share. This software is provided "as is" with no
expressed or implied warranty. I accept no liability for any damage or
loss of business that this software may cause.