Jump to content

INetGet and INetRead return different values


Go to solution Solved by sahsanu,

Recommended Posts

I've been having some trouble lately while trying to download (and parse) some vcard files at the same time. In a nutshell, it seems like the encoding method does not work properly when using INetRead(). Here's an example

Outputted relevant VCard text when using INetGet and storing the information in a temporary file which is then read and deleted. This is the correct way to display the information (note Ureña) $VCard1 below:

Av. Pedro Henriquez Ureña No. 157=0D=0A;Santo Domingo;;;Dominican Republic;

Here is the same line outputted when read with INetRead and converted (Note Ure�a) $VCard2 Below:

Av. Pedro Henriquez Ure�a No. 157=0D=0A;Santo Domingo;;;Dominican Republic;

Here is the URL of the example VCard: http://www.squiresanders.com/Professionals/AttorneyVCard.aspx?lawyer=5713

and my relevant code for both examples:

InetGet($URL,$FileName,1,0)
$VCard1= FileRead($FileName)
filedelete($FileName)

$VCard2 = BinaryToString(InetRead($URL,1), 4)

the encoding of the file I'm fairly certain is UTF-8, since that's what was sent in the response headers when I checked the data my browser was sending, but I really can't be sure except to say that I've tried each of the options for the BinaryToString function and all returned gibberish except UTF8 conversion. If anyone could be of any help in solving this mystery, I'd be very grateful!

Edited by FlashpointBlack
Link to comment
Share on other sites

  • Solution

Hello,

Using BinaryToString default flag [1] works for me:

$VCard2 = BinaryToString(InetRead($URL,1),1)

As flag 1 for BinaryToString is the default one, you could use the function without this parameter:

$VCard2 = BinaryToString(InetRead($URL,1))

As I said, using your url example it returns the Last Name of that person with he right encode "Alcántara" instead of "Alc?ntara".

Edit: I forgot to say that Ureña is showed with right encode too "Ureña" instead of "Ure?a" ;)

Cheers,

sahsanu

Edited by sahsanu
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...