將字元轉換為16位元碼
1: namespace StringPlus
2: {
3: /// Convert a unsigned char to a hexadecimal string without "0x".
4: std::string ToHex(unsigned char uc)
5: {
6: char _buff[8];
7: int _len = sprintf(_buff, "%02X\0", uc);
8: return std::string(_buff);
9: }
10:
11: /// Convert a unsigned char to a hexadecimal string within "0x".
12: std::string To0xHex(unsigned char uc)
13: {
14: char _buff[8];
15: int _len = sprintf(_buff, "0x%02X\0", uc);
16: return std::string(_buff);
17: }
18: }