From 6a1da40b09fb7292c6b69ed6c34b9161dd911dff Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Thu, 4 Sep 2025 02:18:57 +0300 Subject: [PATCH] fix(mql): trim trailing null in to_hex Remove null terminator inserted by StringToCharArray to avoid stray 00 in hex output. --- hmac.mqh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hmac.mqh b/hmac.mqh index 6d1c3ec..66328d9 100644 --- a/hmac.mqh +++ b/hmac.mqh @@ -54,6 +54,9 @@ namespace hmac { string to_hex(const string& str, bool is_upper = false) { uchar bytes[]; StringToCharArray(str, bytes, 0, -1, CP_UTF8); + int len = ArraySize(bytes); + if (len > 0 && bytes[len - 1] == '\0') len -= 1; + ArrayResize(bytes, len); return to_hex(bytes, is_upper); }