Improved hex handling.

This commit is contained in:
n-a-c-h
2006-03-29 02:00:21 +00:00
parent e661b063ac
commit 36e293456f

View File

@@ -210,6 +210,15 @@ string hex_convert(string str)
str.insert(h_pos-h_len+1, "0x");
}
for (size_t i = 0; i < str.size(); i++)
{
if ((!i || !isxdigit(str[i-1])) && (str[i] == '0') && (str[i+1] != 'x'))
{
str.erase(i, 1);
i--;
}
}
return(str);
}