Remove a local text escape function.

There is a global function for escaping, so use that function.
Use a more efficient way to clear a string.
Use a const ref variable instead of const value.

Issue found by cppcheck.
Use a const ref variable instead of const value.

Issue found by cppcheck.
Use a const ref variable instead of const value.

Issue found by cppcheck.
Use a const ref variable instead of const value.

Issue found by cppcheck.
Use a const ref variable instead of const value.

Issue found by cppcheck.
Use a const ref variable instead of const value.

Issue found by cppcheck.
Limit variable scope.

Issue found by cppcheck.
Limit variable scope.

Issue found by cppcheck.
Limit variable scope.

Issue found by cppcheck.
Limit variable scope.

Issue found by cppcheck.
Merge branch 'cppcheck'