Skip to content

Commit 3a853a4

Browse files
authored
fix(mql): trim trailing null in to_hex
Remove null terminator inserted by StringToCharArray to avoid stray 00 in hex output.
1 parent b59b2d9 commit 3a853a4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

hmac.mqh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ namespace hmac {
5454
string to_hex(const string& str, bool is_upper = false) {
5555
uchar bytes[];
5656
StringToCharArray(str, bytes, 0, -1, CP_UTF8);
57+
int len = ArraySize(bytes);
58+
if (len > 0 && bytes[len - 1] == '\0') len -= 1;
59+
ArrayResize(bytes, len);
5760
return to_hex(bytes, is_upper);
5861
}
5962

0 commit comments

Comments
 (0)