Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 10th, 2003, 12:09 AM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default PLEASE: getting contents from remote server.

Hi!

I'm using XMLHTTP activeX object to access pages in remote servers.
It's working fine but when the contents is text with chars like "à" or "è" it returns unknown information. Actually it melts this char with the following byte and returns only one!

Maybe this has something to do with Unicode or ASCII defaults. do you know what it can be?

thx!!

 
Old November 10th, 2003, 05:32 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Usually indicates that the server dishing out the page is not setting the encoding accurately. For example it says the page is in utf-8 when it is not, do you have any control over the source?

--

Joe
 
Old November 10th, 2003, 10:19 AM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

Hi,

I have all the control over the source.. it's just a remote server but I have access to the files.. The enconding I need is:

iso 8859-1 (Latin-1)

I must force the server to send it has this.. Ill try to check the HEADER msg containing the enconding it is using!

see ya later!
(do you have any ideis how to force it to send it in a determined iso?)

THX

 
Old November 10th, 2003, 10:28 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Show the code used to create the document, a brief bit that is. What server-side technique are you using, ASP, PHP etc?

Joe (MVP - xml)
 
Old November 10th, 2003, 10:40 AM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

Ok.. I'm using JSCRIPT.
This is a HTA that gets info from a file and them writes it in a file. The file is a .JS (TEXT) and its enconded in iso 8859-1.

Here is the code I use to retrieve and write the file:
The commented code is the part that writes. It works but not with this enconding. I think the server is not returning the correct enconding like you said:

function GetNewData(address) {
   var objFSO, resposta;

   try {
    objFSO = new ActiveXObject("Scripting.FileSystemObject");
    resposta = new ActiveXObject("Msxml2.XMLHTTP");
    resposta.open("GET",address,false);
    resposta.send();

    document.write(resposta.getAllResponseHeaders());
    //returned contents need to be [iso 8859-1 Latin-1 / ANSI] in order to write to file

    //TextFile = objFSO.CreateTextFile(".\\files\\db\\series.js");
    //TextFile.write(resposta.responseText);
    //TextFile.Close();
   }
   catch(e){
    alert("Failure while updating the DataBase!\nDescription: "+e.description);
    return;
   }
}


And here the headers from the server:

Server: Microsoft-IIS/5.0
X-Powered-By: ASP.NET
Date: Mon, 10 Nov 2003 22:36:34 GMT
Content-Type: application/octet-stream
Accept-Ranges: bytes
Last-Modified: Mon, 10 Nov 2003 11:01:25 GMT
ETag: "10d622fc79a7c31:992"
Content-Length: 141861


 
Old November 10th, 2003, 11:11 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Yes, but what is the code on the server that creates the response, that's where the problem lies.
Is it an internet accessible url?
--

Joe
 
Old November 10th, 2003, 11:47 AM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

This is supposed to be an Internet accessible address although I'm just testing it in a Intranet.

The problem is that there is no server-side code!! This is a HTTP Request just like your browser makes to the server.. IIS then returns what he is supposed to return acording to the request I made..

Here I am just requesting a page.. The server returns it the way it wants! I can't control it.. What I can't understand is why even the raw answer returned by the property responseBody(Byte-array) has the wrong bytes! If at least this property was correct I could make VBScript code to process the byte array. But even the binary answer is wrong!

if you have any clue please let me know and THX!

 
Old November 10th, 2003, 12:35 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well the header says "Content-Type: application/octet-stream" which is not consistent with a page encoded as iso 8859-1. Is an htm page or a binary file?


--

Joe
 
Old November 10th, 2003, 12:41 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

Hum.. Good news..

I think there is no way to control what the server sends. I mean.. This issue cannot be treated server-side.
I've been reading some stuff and it looks like microsoft like the octet-like content description for all the contents it sends as long as the software can take into consideration the file extention.

In my case I have to do the same.. I know the file is text in Latin-1 iso. It is sent has an array of bytes that is CORRECT. I thought it was a wrong byte array but it is a correct byte array.

The problem is in the responseText property that assumes the file is unicode and for chars over &H7F (the case of 'à') it messes everything up. The solutions are:

1)
Find a way to force resposeText of the XHMHTTPRequest to treat the data as Latin-1.
(Don't think it's possible)

2)
Handle the byte array. (ResponseBody property)
(it will work but cannot be done with JScript. Have to use VBScript)

3)
Process the return Stream Object. (ResponseStream property)
This can be done in JScript. I think it will work because there is a property of the Stream Object where you can select the charset iso)



I will try the Stream because will be easier to do than process binary data in VBScript. The inly problem is that they say ResponseStream property returns a Stream Object but I still can't use it.. the code returns an Object that's for sure. But I have to find out how to say that the object is a Stream Object. Do you know how to do this?

Thx!

 
Old November 10th, 2003, 12:44 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

Yes. I am sure that the file is text. This code works just fine if the file has only Standart ASCII chars (0-127).

:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
server error when uploading to remote server ammweb ASP.NET 1.0 and 1.1 Basics 7 July 30th, 2006 01:51 AM
VB Express and SQL server on remote server questio HoosierDaddy61 Visual Basic 2005 Basics 0 February 22nd, 2006 11:27 AM
connecting web server and remote db server via asp moreyt Classic ASP Databases 0 May 31st, 2005 12:13 AM
Linking Remote Sql Server with Web server yeetesh Pro VB Databases 1 May 26th, 2005 04:13 AM
connecting to remote server moushumi SQL Server 2000 3 March 29th, 2004 07:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.