FlashpointBlack Posted October 11, 2013 Share Posted October 11, 2013 (edited) 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 October 11, 2013 by FlashpointBlack Link to comment Share on other sites More sharing options...
Solution sahsanu Posted October 12, 2013 Solution Share Posted October 12, 2013 (edited) 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 October 12, 2013 by sahsanu FlashpointBlack 1 Link to comment Share on other sites More sharing options...
FlashpointBlack Posted October 13, 2013 Author Share Posted October 13, 2013 wow. I swear I tried it without specifying an option. must have completely spaced out... Thanks so much sahsanu, I really appreciate you looking into this for me! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now