[Javascript] Converting to string data...better explanation of the problem...
Carlos
carlos at unica.cu
Wed May 2 16:39:57 CDT 2001
I want to convert a variant data into a string, because I have to print it,
in others words I read a binary file, and I want to print the content of the
file. The code works prefectly (no errors messages), but the result is not
what I desire...here is the code...
function Load(FileName) {
var BinFile, BinData;
BinFile = Server.CreateObject("ADODB.Stream");
BinFile.Open();
BinFile.LoadFromFile(FileName);
BinFile.Type = adTypeBinary;
BinData = BinFile.Read();
BinFile.Close();
BinFile = null;
Response.Write(BinData);
}
according to all references I've read, the function Stream.Read(numBytes)
reads numBytes from a stream and return the data as a Variant, but I can't
find that type (Variant) in any place of my Javascript's Tutorial, and I
need to convert it to a string to display it, cause the sentence
"Response.Write(BinData)" only displays "????" symbols...
How can I convert it to a string??? In extension,: how can I convert it to
any data???, for example to an Integer?...I mean:
BinData = BinFile.Read(1);
and after this convert BinData to and Integer...
Thanks
Carlos
PD: I want to warning, that if the file the function is loading is a text
file, and I replace the lines:
BinFile.Type = adTypeBinary;
BinData = BinFile.Read();
by...
BinFile.Type = adTypeText;
BinData = BinFile.ReadText();
it works perfectly, but I don't want to do so, I want to read the file as a
binary file.
More information about the Javascript
mailing list