Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: 1 [2] 3 4 ... 10
 11 
 on: March 13, 2024, 10:34:02 am 
Started by Francois G. - Last post by Leo S.
Hi Francoise, to cut at a byte boundary of x you even *must* use FGL_LENGTH_SEMANTICS=BYTE because getLength of the String returns the number of bytes.
So Rene did demonstrate how easy it is to iterate thru because as long as you increase the index passed to getCharAt properly with the next character byte length you always get the correct character.
If the index goes beyond your byte boundary , just go one position back and do a subString.

HTH , Leo
Code
  1. MAIN
  2.  DEFINE s, s2 STRING
  3.  IF fgl_getenv("FGL_LENGTH_SEMANTICS") == "CHAR" THEN
  4.    DISPLAY "must not have CHAR length semantics to count bytes"
  5.    RETURN
  6.  END IF
  7.  LET s = "🙁🙂ab£c🙁"
  8.  LET s2 = cutAtByteLength(s, 14)
  9.  DISPLAY SFMT("s:%1 slen:%2 s2:%3 s2len:%4", s, length(s), s2, length(s2))
  10.  LET s = "🙁🙂x"
  11.  LET s2 = cutAtByteLength(s, 8)
  12.  DISPLAY SFMT("s:%1 slen:%2 s2:%3 s2len:%4", s, length(s), s2, length(s2))
  13. END MAIN
  14.  
  15. FUNCTION cutAtByteLength(s STRING, maxByteLength INT) RETURNS STRING
  16.  VAR l = s.getLength() --byte length whole string
  17.  DISPLAY "source has length:", l
  18.  VAR i = 1
  19.  WHILE i <= l
  20.    VAR c = s.getCharAt(i)
  21.    VAR clen = c.getLength() --byte length one char
  22.    LET i += clen
  23.    DISPLAY SFMT("i:%1,c:%2,len:%3", i, c, c.getLength())
  24.    IF i - 1 > maxByteLength THEN
  25.      RETURN s.subString(1, i - 1 - clen)
  26.    END IF
  27.  END WHILE
  28.  RETURN s
  29. END FUNCTION
  30.  

 12 
 on: March 13, 2024, 09:06:16 am 
Started by Francois G. - Last post by Rene S.
The program above produces:
Code
  1. $ FGL_LENGTH_SEMANTICS=BYTE fgl ll1
  2. s:ab€c d l:8 w:6 number_of_logical_chars:6
  3. s:123456 l:6 w:6 number_of_logical_chars:6
  4. $ FGL_LENGTH_SEMANTICS=CHAR fgl ll1
  5. s:ab€c d l:6 w:6 number_of_logical_chars:6
  6. s:123456 l:6 w:6 number_of_logical_chars:6
  7.  

The number of logical chars does not depend on FGL_LENGTH_SEMANTICS

 13 
 on: March 13, 2024, 09:03:03 am 
Started by Francois G. - Last post by Rene S.
Try this:

Code
  1. MAIN
  2.    DEFINE s STRING
  3.    LET s = 'ab€c d'
  4.    DISPLAY SFMT("s:%1 l:%2 w:%3 number_of_logical_chars:%3",
  5.        s, length(s), fgl_width(s), number_of_logical_chars(s))
  6.    LET s = '123456'
  7.    DISPLAY SFMT("s:%1 l:%2 w:%3 number_of_logical_chars:%3",
  8.        s, length(s), fgl_width(s), number_of_logical_chars(s))
  9. END MAIN
  10.  
  11. FUNCTION number_of_logical_chars(s STRING) RETURNS INT
  12.    DEFINE i, l, n INT
  13.  
  14.    LET l = s.getLength()
  15.    LET i = 1
  16.    LET n = 0
  17.    WHILE i <= l
  18.        VAR c = s.getCharAt(i)
  19.        LET i += c.getLength()
  20.        LET n += 1
  21.    END WHILE
  22.    RETURN n
  23. END FUNCTION
  24.  

BTW: if the string not contains double-width East Asian characters, fgl_width will do the job.

 14 
 on: March 12, 2024, 10:44:14 am 
Started by Nuno T. - Last post by fada b.
Quote
The error message you're seeing means that the functionality you're attempting to utilize (sending a JSON payload in a GET request) isn't supported. According to RESTful principles, JSON payloads are often supplied using POST requests rather than GET requests.

If you need to deliver a JSON payload in a GET request, encode the data as query parameters in the URL. Here's an example of how to change your code to accomplish this:
backrooms game

```python
import com.HttpRequest

LET json = {"articleNumber":"800700"}
LET json_string = STRING(json)
LET encoded_json = com.HttpUtility.urlEncode(json_string)

LET url = "https://xxx/GetProductAvailabilities?data=" + encoded_json
 
LET req = com.HttpRequest.Create(url)
CALL req.setMethod("GET")
CALL req.setHeader("Content-Type", "application/json")
CALL req.setHeader("Accept", "application/json")
CALL req.doTextRequest("")
```

In this code sample, the JSON data is first encoded with the 'com.HttpUtility.urlEncode()' method before being attached to the URL as a query parameter. This allows you to include JSON data in your GET request.

Please keep in mind that encoding sensitive information or big payloads in URLs is not recommended due to security and performance concerns. Consider transmitting JSON payloads via POST requests whenever possible.
I understand, thank you very much.

 15 
 on: March 12, 2024, 10:08:28 am 
Started by Francois G. - Last post by Sebastien F.
No need to wait for Monday
Please contact me directly
Seb

 16 
 on: March 12, 2024, 09:56:51 am 
Started by Francois G. - Last post by Francois G.
Thanks Seb,

We usually have a call with Michelle and Neil on Monday mornings: would you be able to attend, or at least discuss with Neil?

Regards,

 17 
 on: March 12, 2024, 09:53:00 am 
Started by Francois G. - Last post by Sebastien F.
Hello François,

NO!!! You should not have to write such code to split UTF-8 strings at byte level to insert the text into the SQL database!

Please let's have a call to discuss this.

Seb

 18 
 on: March 12, 2024, 09:48:24 am 
Started by Francois G. - Last post by Francois G.
Hi,

Given LANG=en_GB.utf8 and FGL_LENGTH_SEMANTICS unset (defaulting to byte), and given a text typed in by the user containing emojis, accents, UK pound sign (£), quotes and double quotes from a word processor (3-byte UTF-8 characters), I need to be able to split this text into several Informix records (each 200 bytes long) at a UTF-8 character boundary (not at a byte boundary), as well as cut off a string at a certain byte length, but without damaging any UTF-8 towards the end (cut earlier than the byte length, so that all multi-byte UTF-8 characters keep their integrity).

How do I iterate through a STRING, one multi-byte UTF-8 character at a time (not one byte at a time) without changing FGL_LENGTH_SEMANTICS ?

I am currently using a horrible hack:

    FOR f_i = 1 TO f_note_text.getLength()
        LET f_utf8 = f_note_text.getCharAt(f_i)
        LET f_b64  = util.Strings.base64EncodeFromString(f_utf8)
        IF f_b64.getLength() = 4 AND f_b64 MATCHES "*==" THEN
            # 1 byte, 7-bit US ASCII, less than 0x7F
        ELSE
            # More than 1 byte, 8-bit, or byte more than 0x7F, either valid part of a UTF-8 character, or invalid part of a broken UTF-8 character
        END IF
    END FOR

With this semantics, ORD() and ASCII() are less than useful for this purpose.

I can also use "hexdump -C" from  the Linux backend and get all the bytes that I need, but this is very heavy and slow.

In C# there is a function for this:

    bytes = Encoding.UTF8.GetBytes(f_note_text);

Finally I could also write a C shared library (SO file) to do this.

Is there a native 4GL / BDL way to achieve this?

Regards,

 19 
 on: March 12, 2024, 05:32:58 am 
Started by Lu?s T. - Last post by acacia s.
I am trying to secure our webservices uing oAuth.
As I did not find anything natively implemented in Genero (I just found some examples of using oAuth as client, not as a server) I am trying to implement it by myself.
In oAuth the invocation of the webservices receives a Jason Web Token (JWT) in the header that should be validated to confirm the caller as access to the webservice.
The JWT is signed to garantee its integrity and it is when trying to validate the signature where I get stucked.
The signature algorithm is 'RS256' and I am trying to use xml.Signature.verifyString. When I try to set the Signture Key, using The CryptoKey class I get an error.
Code:
let key = xml.CryptoKey.Create("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")
call  key.loadPEM("ciiSBqKB2SY_hcvJdxgzR.pem")
This is the stderr when I run it in AIX (I have set the FGLWSDEBUG variable):
Code:
WS-DEBUG (Security Info)
OpenSSL 1.1.1g  21 Apr 2020
WS-DEBUG END

WS-DEBUG (Security Warning)
Crypto library doesn't have any ZLIB compression algorithm.
WS-DEBUG END

WS-DEBUG (Security Warning)
SSL library wasn't compiled with support of RLE compression.
SSL library wasn't able to initiate the ZLIB compression library.
WS-DEBUG END

WS-INFO (Certificate authority) | Loading from directory /usr/informix/gnrdev1/fgl/web_utilities/certs | Loading from directory /var/ssl/certs
Program stopped at 'teste.4gl', line number 17.
FORMS statement error number -15648.
Xml security operation failed : xmlsec library function failed.
An this the output in Linux
Code:
WS-DEBUG (Security Info)
OpenSSL 1.1.1g  21 Apr 2020
WS-DEBUG END

WS-DEBUG (Security Warning)
Crypto library doesn't have any ZLIB compression algorithm.
WS-DEBUG END

WS-DEBUG (Security Warning)
SSL library wasn't compiled with support of RLE compression.
SSL library wasn't able to initiate the ZLIB compression library.
WS-DEBUG END

WS-INFO (Certificate authority) | Loading from directory /opt/informix/gnr-devstudio-3.20.09/fgl/web_utilities/certs | Loading from directory /etc/ssl/certs | Loading from directory /etc/pki/tls/certs
Program stopped at 'teste.4gl', line number 17.
FORMS statement error number -15648.
Xml security operation failed : crypto library function failed : openssl error: 151584876: PEM routines: get_name no start line.
I attached the pem file. Thanks

Looks like there's something wrong in your code.

 20 
 on: March 11, 2024, 06:20:10 pm 
Started by Christine R. - Last post by Christine R.

 Genero Enterprise 4.01 Maintenance Release :
Genero Browser Client 4.01.22


Four Js is pleased to announce a Maintenance Release of Genero Browser Client 4.01.22.

What's new ...
  • The setting for rowAspect style attribute is changed from "card" to "list".
  • The table menu refers to the menu that allows users to show or hide specific columns, autofit columns depending on the size of the window, and reset the table to its original state.
  • Some mobile front calls are now implemented as standard front calls.
  • The $theme-sidebar-show-child-name variable is added to allow you change how applications are displayed in the Application List on the sidebar.

Please refer to see  https://4js.com/online_documentation/fjs-gbc-manual-html/index.html#gbc-topics/gbc_whatsnew_40122.html


This version also includes the following bug fixes: https://4js.com/support/issue/GBC/4.01.22


It is now downloadable from the website: https://4js.com/download/products/.


All Four Js Genero customers under maintenance have free access to the new release.

Best regards,

Four Js Development Tools

Pages: 1 [2] 3 4 ... 10
Powered by SMF 1.1.21 | SMF © 2015, Simple Machines