View Single Post
Old 01-10-2018, 07:59 AM   #41
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by fundorin View Post
We have dec int position with value 11. Printed as double.
We write position into num1 in hex format as a string, adding "\x" in front and making it two characters, minimum. Printed as a string.
We write num1 into num2 in string format as a string. Printed as a string.
We assign "\x0B" text string as a value to num3. Cannot be printed as a string. Why?!
If we convert it into string with a function, then it can be printed as a string.
How come that direct assignment makes that "\x0B" string a hex value for oscii-bot?
I think the key here is that num1 and num2 refer to strings that are 4 bytes long ("\", "x", "0", and "B"), and num3 refers to a 1 byte string with the value of 11. If you want it to be a 4 byte string, you could use "\\x0B" instead of "\x0B". Does that help?
Justin is offline   Reply With Quote