How to convert ASCII/UNICODE string to hex string? Function/API to convert to hex string
Following is code snippet that converts an UNICODE/WIDE string to HEX string:
1 2 3 4 5 6 7 8 9 10 11 | WCHAR str[] = L"abcd"; // string to be converted to HEX string WCHAR hexStr[MAX_PATH]; // string to store HEX string char *temp = (char *)str; for(i = 0; i < wcslen(str)*2; i++ ) { if (temp[i]) _itow_s (temp[i], hexStr, 3, 16); else wcscat_s(hexStr, 3, L"00"); hexStr += 2; }; |
Following is code snippet that converts an ASCII string to HEX string:
1 2 3 4 5 6 7 8 9 10 11 | char str[] = L"abcd"; // string to be converted to HEX string char hexStr[MAX_PATH]; // string to store HEX string char *temp = str; for(i = 0; i < strlen(str); i++ ) { if (temp[i]) _itoa_s (temp[i], hexStr, 3, 16); else strcat_s(hexStr, 3, "00"); hexStr += 2; }; |
Recent Entries
- It’s time to start farming….
- zFeeder – Making PHP 5.3 + compatible, solving ‘Function ereg_replace() is deprecated’
- How to multilingualize or localize URL in Gallery2 – enhancement of multilang module to create multilingual URLs, Multi-language URL for SEO with Multi Language Module
- Fix for mergelog, fails with error “abort due to a problem” for dummy records of apache access logs
- Shepherds life in mountain
- The modern marriage culture among mate
- Do you know that barter system still exists in most villages in uttarakhand, may be true for many other parts of India also
- How to catch copy paste from explorer using shell extension? ICopyHook alternative for files and folder
- How to convert ASCII/UNICODE string to hex string? Function/API to convert to hex string
- How to solve ‘ReadFile hangs’ for named pipe client/server – sample working code for named pipe