Commit 8d47821e authored by captainwong's avatar captainwong

DUMP_ASC 只打印可打印字符[0x20, 0x7f)

parent 8c4a6b7b
...@@ -192,7 +192,12 @@ inline void dump_asc(const void* buff, size_t buff_len, bool seperate_with_space ...@@ -192,7 +192,12 @@ inline void dump_asc(const void* buff, size_t buff_len, bool seperate_with_space
} }
for (size_t i = 0; i < buff_len; i++) { for (size_t i = 0; i < buff_len; i++) {
std::sprintf(c, "%c", reinterpret_cast<const char*>(buff)[i]); if (std::isprint(reinterpret_cast<const char*>(buff)[i])) {
std::sprintf(c, "%c", reinterpret_cast<const char*>(buff)[i]);
} else {
std::sprintf(c, "$");
}
if (seperate_with_space) { if (seperate_with_space) {
std::strcat(c, " "); std::strcat(c, " ");
} }
......
...@@ -18,6 +18,19 @@ ...@@ -18,6 +18,19 @@
int main() int main()
{ {
jlib::init_logger(L"test");
char data[0x80 - 0x20] = {};
for (int i = 0x20; i < 0x80; i++) {
data[i-0x20] = i;
}
JLOG_ASC(data, sizeof(data));
JLOG_HEX(data, sizeof(data));
data[0] = 31;
JLOG_ASC(data, sizeof(data));
return 0; return 0;
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<ProjectGuid>{155F525A-FA2F-471F-A2DF-9B77E7CCCFA5}</ProjectGuid> <ProjectGuid>{155F525A-FA2F-471F-A2DF-9B77E7CCCFA5}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>test</RootNamespace> <RootNamespace>test</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment