The output 12594 results from a programming error. Entering ‘12’ violates the rules for specification of a single 8 bit character and on my IDE, causes the compiler to emit a warning. It probably should be a fatal error rather than a warning.
When you output ‘12’ you are outputting 2 characters, a ‘1’ and then a ‘2’, this results in hex 31 or dec 49 being transmitted followed by a 32hex / 50dec, if you concatinate the two into a single integer then you get 12594, sending the 10 works out to be 12592, 11=12593
Binary of 49 = 00110001
Binary of 50 = 00110010
How these concatinate , depends on the compiler.
Here these concatinate as : 00110001 00110010
In some other compiler they may concatinate as :
00110010 00110001
The print statement is interpreting this as an integer (16bits) instead of two 8 bit characters because in C the character literal is defined as an int and your providing just the right number of 8 bit characters to make an int.
If you type = ‘312’ , then the compiler would consider last two characters only because the size of int is 2 bytes in Arduino IDE.