This is the right track, you do need to check 0
. And you are loading in op
correctly. But the way that you work with the comment is incorrect.
The characters are coded within UTF-8, so using load_uint
will not work as expected, since it expects binary encoding.
Instead, you will have to parse it:
() recv_internal(int balance, int msg_value, cell in_msg_full, slice in_msg_body) {
int op = in_msg_body~load_uint(32);
if (op == 0) {
;; load in the first 8 bits because of UTF-8 encoding
int comment = in_msg_body~load_uint(8);
;; in UTF-8, 50 is the character for 2, because 50 = 0x32
var state = 0;
if (comment == 50) {
state = 2;
}
set_data(begin_cell().store_uint(op, 32).store_uint(comment, 8).store_int(state, 8).end_cell());
}
}
Refer to UTF-8 here: https://www.utf8-chartable.de/