Changing file format

Just starting out? Need help? Post your questions and find answers here.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 596
Joined: Tue Jan 04, 2011 6:21 pm

Changing file format

Post by SPH »

Hi,

with this code in pb5.11, it displayed the correct result (numbers and letters). But when trying to upgrade the code to 6.04, I get Chinese characters.
As the file was entirely created by PB code, I wonder how it could have changed along the way...

THANKS

Code: Select all

ProcedureDLL.s Url2Text2(Url.s, OpenType.b,ProxyAndPort.s)
  ;/ Author : Pille
  isLoop.b=1
  INET_RELOAD.l = $80000000
  hInet.l=0
  hURL.l=0
  Bytes.l=0
  Buffer.s= Space (32768)
  RES.s= ""
  hInet = InternetOpen_ ( "" , OpenType, ProxyAndPort, "" , 0)
  hURL = InternetOpenUrl_ (hInet, Url, #Null , 0, INET_RELOAD, 0)
  Repeat
    InternetReadFile_ (hURL,@Buffer, Len (Buffer), @Bytes)
    If Bytes = 0
      isLoop=0
    Else
      RES = RES + Left (Buffer, Bytes)
    EndIf
  Until isLoop=0
  InternetCloseHandle_ (hURL)
  InternetCloseHandle_ (hInet)
  ProcedureReturn RES
EndProcedure
ProcedureDLL.s Url2Text(Url.s)
  ProcedureReturn Url2Text2(Url,1, "" )
EndProcedure 


url$="http://hexascrabble.com/php2024.php"
load$=Url2Text(url$)
Debug load$

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
Kiffi
Addict
Addict
Posts: 1509
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Changing file format

Post by Kiffi »

use HTTPRequest():

Code: Select all

HttpRequest = HTTPRequest(#PB_HTTP_Get, "http://hexascrabble.com/php2024.php")

If HttpRequest
  
  Debug "StatusCode: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
  Debug "Response: " + HTTPInfo(HTTPRequest, #PB_HTTP_Response)
  
  FinishHTTP(HTTPRequest)
  
Else
  Debug "Request creation failed"
EndIf
Hygge
User avatar
SPH
Enthusiast
Enthusiast
Posts: 596
Joined: Tue Jan 04, 2011 6:21 pm

Re: Changing file format

Post by SPH »

That's good !!

THX 👀

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
infratec
Always Here
Always Here
Posts: 7664
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Changing file format

Post by infratec »

Didn't you read the memo :mrgreen:

A long time ago ASCII/UTF8 was the deafult for strings in PB

Then it changed to Unicode.
So all old programs or API code which returns ASCII needs to convert the ASCII stuff to Unicode.

Or ... avoid the API stuff.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 596
Joined: Tue Jan 04, 2011 6:21 pm

Re: Changing file format

Post by SPH »

infratec wrote: Sun Jan 07, 2024 3:03 pm Didn't you read the memo :mrgreen:
hummmm , no :|

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
Post Reply