cancel
Showing results for 
Search instead for 
Did you mean: 

Converting Characters with PB 12.6 - CharA not working correctly?

Former Member
0 Kudos

Hi,

i am just testing a migrated Powerbuilder application from PB 9.5 to 12.6. here we have some functionality to read data from a Blob and show it later on with a datawindow.

In this context i discover currently a strange behavior.


e.g.

// Get record type (1 Byte)

lstr_record.record_type = CharA(Blobmid(lb_block, 3))

This code is working in Powerbuilder 9.5 (only Char instead of CharA) and Powerbuilder 12.5 (which i tested some weeks ago), but in Powerbuilder 12.6 i get some strange chinese character.

I was trying to get deeper into the issue and have converted the Blob into Byte Array and i looked to the 3rd byte in above case and i got 67 = 43hex, which would be the expected character 'C'.

Is this a bug in Powerbuilder 12.6? Or what do i missing?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Henning,

the problem seems to be the implicit conversion from a Blob with length 1 to an integer. Try to add a lblb_00 which is declared as "blob{1} lblb_00".

... = charA( BlobMid( lb_Block, 3, 1 ) + lblb_00 )

charA() takes a string or an integer, in this case obviously an integer and an integer is 2 bytes long.

HTH

Bernhard

Former Member
0 Kudos

Hi Bernhard,

i did not tried yet you suggestion, but i found now another way, which works fine.

Solution looks like this:

// Get record type (1 Byte)

lstr_record.record_type =  String(Blobmid(lb_block, 3,1), EncodingANSI!)

This will solve my issue, but anyway strange to see, that code, which is working in Powerbuilder 9.5 and Powerbuilder 12.5,  is not working anymore in Powerbuilder 12.6.

Regards

Henning

Former Member
0 Kudos

Hi Henning;

  FWIW: If  this exact code worked in PB 12.5.x then I suspect that its a bug in PB 12.6 as the code base between the two PB versions should be the same - AFAIK.

Just for interest sake though, can you try ...

lstr_record.record_type = CharA ( Blobmid ( lb_block, 3, 1 ) )

Regards .. Chris

Former Member
0 Kudos

Hi Chris,

That i tried too, same result

This code does not work:

// Get record type (1 Byte)

lstr_record.record_type = CharA(Integer(Blobmid(lb_block, 3,1)))

This code gives the expected result !!!

Byte lb_byte[]

lb_byte = getByteArray(Blobmid(lb_block, 3, 1))

lstr_record.record_type = CharA(Integer(lb_byte[1]))

It looks, really like a bug. For me it seems to be, that CharA reads 2 bytes instead of only one

Henning

Former Member
0 Kudos

I agree... I think that either BlobMid or CharA are reading two bytes instead of one. This certainly looks like a case should be opened with SAP technical support for this.

I'm glad though that you have a workaround though using the GetByte/GetByteArray () methods!