tell me how MAC OS treat string and text data internally

can any body tell, how stirng data are save internally in a file?

actually I am writing a script which set IPTC data in Image file, but when we set iptc fields to a file, the data is saved in absurd manner.

if we set IPTC value like this, set file IPTC to file_name{caption value, caption writer, …} then we get result as

dle2STXT>0ktxtTEXT0Caption Valuektstysty|0000

any body tell, why such type of raw data is saved in the file, and what the solution to solve it.

aashi.