HB_Base64Encode() unexpected result

HB_Base64Encode() unexpected result

Postby hua » Tue May 15, 2018 6:38 pm

In xHarbour's doc, it has this sample.
Code: Select all  Expand view
PROCEDURE Main
      LOCAL cString := "xHarbour"
      LOCAL cBase64 := HB_Base64Encode( cString, Len(cString ) )

      ? cBase64                     // result: eEhhcmJvdXI==
      ? HB_Base64Decode( cBase64 )  // result: xHarbour

   RETURN
 


but when I tested using Harbour I get
Code: Select all  Expand view
eEhhcmJv\r\ndXI=\r\n


Why the different result? Which one is correct?
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: HB_Base64Encode() unexpected result

Postby Lailton » Tue May 15, 2018 9:47 pm

Try to remove the second parameter and leave only hb_base64encode( cString )

For example:
Code: Select all  Expand view
hb_base64encode( "Harbour" ) -> eEhhcmJvdXI=
Regards,
Lailton Fernando Mariano
User avatar
Lailton
 
Posts: 153
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil

Re: HB_Base64Encode() unexpected result

Postby hua » Thu May 17, 2018 3:10 am

Thanks Lailton! That solution get rid of the unexpected CRLF
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 55 guests

cron