I have a function which outputs the integer 128 as a character into a file. When I reopen this file to read that character with the next function, it reads the sequence of characters in the form 60 49 54 114 48 48 56 48 62. When I output 127 into the file and then read it again, next correctly returns 127, so what's wrong with the characters > 128?. How can I read the actual integer representation of the character correctly?
Code for outputting an integer into a file
|inputfile args name|
args := Smalltalk arguments.
name := args at: 1.
inputfile := FileStream open: name mode: FileStream write.
inputfile << 128 asCharacter.
inputfile close.
Code for reading a file
|inputfile args name|
args := Smalltalk arguments.
name := args at: 1.
inputfile := FileStream open: name mode: FileStream read.
[inputfile atEnd ~= true] whileTrue:[stdout << inputfile next asInteger.].
inputfile close.