1. Durai Raj
  2. PowerBuilder
  3. Friday, 6 January 2023 18:47 PM UTC

Hi There,

Is there any way to save (or) store the encrypted UTF-8 encoding value to string data type variable without any changes.

For example,
encrypted UTF-8 encoding value is: #›@Š%&ž#•
string data type variable is: #›@Š%&ž#•

In the above example, "amp;" is not there when i save (or) store the encrypted UTF-8 encoding value to string data type variable. Is there any way to save as UTF-8 itself. Please advise.

René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 11 January 2023 06:58 AM UTC
  2. PowerBuilder
  3. # 1

Hi Durai,

The idea of PBDOM is to easily handle the XML format. So it does the encoding of special characters like "&" for you.

If you have "a & b" in your XML it will return it as "a & b" to you because it is exactly what it means.

(If you want to get  "a & b" it must be in xml as "a & b" or as CDATA section.)

AFAIK you can't get plain (unencoded) XML text with PBDOM.

 

You could try Microsofts MSXML Activex. It has more options and I think you can also get the xml representation of a node.

HTH,

René

Comment
There are no comments made yet.
Durai Raj Accepted Answer Pending Moderation
  1. Tuesday, 10 January 2023 14:17 PM UTC
  2. PowerBuilder
  3. # 2

Hi Sivaprakash,

Thanks for your response. It's fine if I hard code the value and store from one variable to another variable. how i can store '&' along with '&' through below GetChileElement and gettext()

lo_client = Create httpClient
lpbdom_Builder = CREATE PBDOM_BUILDER
lo_client.SetRequestHeader("Content-Type", "text/xml; charset=utf-8")
lo_client.sendrequest('POST',ls_url,ls_body)
lo_client.GetResponseBody(ls_data)

lpbdom_Doc = lpbdom_Builder.BuildFromString(ls_data)
ls_username = lpbdom_Doc.GetRootElement().&
GetChildElement("Body", "soap","http://schemas.xmlsoap.org/soap/envelope/").&
GetChildElement("GetEncryptionResponse","","http://url_name/").&
GetChildElement("GetEncryptionResult","","http://url_name/").gettext()

 

 

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 9 January 2023 11:42 AM UTC
  2. PowerBuilder
  3. # 3

Hello,

I tried to same in PB, (2022 1892)

String ls_one, ls_two
ls_one = '#›@Š%&ž#•'
ls_two = ls_one
Messagebox('1', 'One : ' + ls_one + '~r~nTwo : ' + ls_two)

I get the above result.   I think I could not understand the issue well enough.

Happiness Always
BKR Sivaprakash

 

Comment
  1. Miguel Leeuwe
  2. Monday, 9 January 2023 11:57 AM UTC
that's why I asked for some code for us to understand, but no luck so far.
  1. Helpful
  1. Sivaprakash BKR
  2. Monday, 9 January 2023 12:30 PM UTC
Then we need to wait for the OP to respond, Miguel.
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 9 January 2023 11:36 AM UTC
  2. PowerBuilder
  3. # 4

Hello,

If I understand the issue correctly, you want to save the value (#›@Š%&ž#•) into a string data type.  Am I right?

I tried saving the value through the following query

Update table1
Set field1 = '#›@Š%&ž#•'
Where key = 'kljth3df'

I could store it.  My database is PostgreSQL 15 and I tried the above query through PG Admin4 6.16.   

Here is the screen shot after storing the value in the database.  

Correct me If my understanding is wrong.

Happiness Always
BKR Sivaprakash

 

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 9 January 2023 07:22 AM UTC
  2. PowerBuilder
  3. # 5

Hello,

Can you try URLEncode and URLDecode ?

Happiness Always
BKR Sivaprakash

 

Comment
  1. Miguel Leeuwe
  2. Monday, 9 January 2023 09:19 AM UTC
Hi,

UrlEncode and Decode will convert all characters: spaces, < > etc.

  1. Helpful
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Sunday, 8 January 2023 15:35 PM UTC
  2. PowerBuilder
  3. # 6

I think everyone is missing the point here. "&amp;" isn't a UTF-8 specific encoding, it's specific to HTML/XML because the & symbol gets translated. When the data gets extracted from the incoming string it's converting the string encoded version of an '&' back to it's normal string version.

Here's a Wiki link for special XML characters.

Comment
  1. Miguel Leeuwe
  2. Sunday, 8 January 2023 17:22 PM UTC
Hi Brad,

I'm not sure if I understand well, but I'm trying. What I've understood, is that the & is already present in the returned response. So I can't see how it would disappear if you simply assign that receiving string to another string.

Maybe you understand better what's going on, but I think we would have to see some code that illusttrates the problem.

  1. Helpful
There are no comments made yet.
Durai Raj Accepted Answer Pending Moderation
  1. Saturday, 7 January 2023 15:54 PM UTC
  2. PowerBuilder
  3. # 7

Hi MiguelL,

In my application, we consume one web service using HTTPClient and the response we receive back as xml format. Content-Type: text/xml; charset=utf-8.

The response xml have &amp; wherever the & present. Example, #›@Š%&amp;ž#• is one of the encrypted response from the web service.
I need to save the same value to one of the variable and try to use for my further validations.

Whenever i save the above into one of the string data type
variable then by default amp; is not saving whenever &amp; comes. It means, when I save #›@Š%&amp;ž#• to string data type variable
then it save as #›@Š%&ž#• (i.e. without amp;)

Is there any way to save this #›@Š%&amp;ž#• as same value and reuse the variable ?

 

Regards,

Durai

Comment
  1. Miguel Leeuwe
  2. Sunday, 8 January 2023 17:20 PM UTC
So ... If you already have the & within your string variable, when do you say that it disappears?

regards
  1. Helpful
  1. René Ullrich
  2. Monday, 9 January 2023 08:18 AM UTC
Hi Durai,

How do you extract the value from response? Do you use any XML processing logic (e.g. PBDOM)? In this case it is normal that "&amp;" will be changed to "&" because "&amp;" ist just a encoding für "&" in XML and the value will be decodes if you access it.
  1. Helpful
  1. Durai Raj
  2. Thursday, 19 January 2023 15:46 PM UTC
Hi Rane,

Yes, am using PBDOM.



lo_client = Create httpClient

lpbdom_Builder = CREATE PBDOM_BUILDER

lo_client.SetRequestHeader("Content-Type", "text/xml; charset=utf-8")

lo_client.sendrequest('POST',ls_url,ls_body)

lo_client.GetResponseBody(ls_data)





lpbdom_Doc = lpbdom_Builder.BuildFromString(ls_data)

ls_username = lpbdom_Doc.GetRootElement().&

GetChildElement("Body", "soap","http:URL").&

GetChildElement("GetEncryptionResponse","","http:URL").&

GetChildElement("GetEncryptionResult","","http:URL").gettext()



How shall we extract & store the xml value.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 6 January 2023 21:29 PM UTC
  2. PowerBuilder
  3. # 8

Hi,

Where / how is your UTF-8 data stored? Where do you get it from and how.

You can store data in a blob variable and then use the String() function, specifying the Encoding that you want. See the help on the String() function.

Not sure if that helps you.

If you can, give us some code so we understand better what it is that you want to do exactly.

regards,

MiguelL

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.