Mar-28-2019, 05:57 PM
Hello!
I have a class with instance attributes. I need to create an object with each instance having its own values (some are ints, others are strings). Each instance value needs to be converted to binary and saved to a file that will be accessed and updated. My problem is saving the attributes with string values to a specific number of bytes. Each attribute value needs to be a specific number of bytes. I think I know how to convert the integer values but I can't find anything to help with the strings. I can get how large each string is in bytes but I need to save it to a specific byte size, no matter what size it actually is. Is there a way to pad it or something?
Thanks in advance,
I have a class with instance attributes. I need to create an object with each instance having its own values (some are ints, others are strings). Each instance value needs to be converted to binary and saved to a file that will be accessed and updated. My problem is saving the attributes with string values to a specific number of bytes. Each attribute value needs to be a specific number of bytes. I think I know how to convert the integer values but I can't find anything to help with the strings. I can get how large each string is in bytes but I need to save it to a specific byte size, no matter what size it actually is. Is there a way to pad it or something?
Thanks in advance,