mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 05:45:20 +00:00
- Start rosapps rearrange and cleanup process.
svn path=/trunk/; revision=34303
This commit is contained in:
parent
0a0a13a41c
commit
2012315e5a
1206 changed files with 81 additions and 81 deletions
49
rosapps/applications/sysutils/utils/sdkparse/binary2cstr.cpp
Normal file
49
rosapps/applications/sysutils/utils/sdkparse/binary2cstr.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
// binary2cstr.cpp
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif//_MSC_VER
|
||||
|
||||
#include "binary2cstr.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
string binary2cstr ( const string& src )
|
||||
{
|
||||
string dst;
|
||||
for ( int i = 0; i < src.size(); i++ )
|
||||
{
|
||||
char c = src[i];
|
||||
switch ( c )
|
||||
{
|
||||
case '\n':
|
||||
dst += "\\n";
|
||||
break;
|
||||
case '\r':
|
||||
dst += "\\r";
|
||||
break;
|
||||
case '\t':
|
||||
dst += "\\t";
|
||||
break;
|
||||
case '\v':
|
||||
dst += "\\v";
|
||||
break;
|
||||
case '\"':
|
||||
dst += "\x22";
|
||||
break;
|
||||
default:
|
||||
if ( isprint ( c ) )
|
||||
dst += c;
|
||||
else
|
||||
{
|
||||
dst += "\\x";
|
||||
char tmp[16];
|
||||
_snprintf ( tmp, sizeof(tmp)-1, "%02X", (unsigned)(unsigned char)c );
|
||||
tmp[sizeof(tmp)-1] = '\0';
|
||||
dst += tmp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue