HB_Base64Encode() unexpected result

Post Reply
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

HB_Base64Encode() unexpected result

Post by hua »

In xHarbour's doc, it has this sample.

Code: Select all | Expand

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

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
User avatar
Lailton
Posts: 172
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Has thanked: 2 times
Been thanked: 7 times
Contact:

Re: HB_Base64Encode() unexpected result

Post by Lailton »

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

For example:

Code: Select all | Expand

hb_base64encode( "Harbour" ) -> eEhhcmJvdXI=
Regards,
Lailton Fernando Mariano
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: HB_Base64Encode() unexpected result

Post by hua »

Thanks Lailton! That solution get rid of the unexpected CRLF
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
Post Reply