Use C++ to manipulate strings

Change-Id: I76c659459854f712d9a149ec31af3eb11c47636b
Reviewed-on: http://review.couchbase.org/32734
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>