From 7c8e31fc057859d08610f17f669fdfcaf2fc2956 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 12 Dec 2008 08:13:34 +0000 Subject: All of those changes I thought I'd already committed. The taf writer handles binary data much better, actually escaping it properly and not stopping on null. Bu::FString has an iterator, it's actually just a raw datatype, but it may have more function later, so careful assuming that it's a char and using it in any non-iterator like way. Also augmented the taf unit test, and added the Bu::CacheCalc base class, the rest of the simple develpment cycle will happen between here and project hhp. --- src/tafwriter.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/tafwriter.cpp') diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp index c30bc67..8e5fcdc 100644 --- a/src/tafwriter.cpp +++ b/src/tafwriter.cpp @@ -93,12 +93,18 @@ void Bu::TafWriter::writeString( const Bu::FString &str ) if( str.getStr() == NULL ) return; sOut.write("\"", 1 ); - for( const char *s = str.getStr(); *s; s++ ) + for( Bu::FString::const_iterator s = str.begin(); s != str.end(); s++ ) { if( *s == '\"' ) sOut.write("\\\"", 2 ); else if( *s == '\\' ) sOut.write("\\\\", 2 ); + else if( *s < 32 || *s > 126 ) + { + char buf[5]; + sprintf( buf, "\\x%02X", (unsigned char)*s ); + sOut.write(buf, 4 ); + } else sOut.write( s, 1 ); } -- cgit v1.2.3