Jul 23, 2024 LZStringCompress, the method compress and decompress data through sockets LZStringCompress is a String encoding library, helping to speed up communication between the server and applications such as Android and Webapp faster and with a certain level of security. Instead of string communication which will cause data insecurity, using LZStringCompress will help improve the speed of your applications in case of large text volumes. LZStringCompress is currently a wrapper for Javascript, B4J, B4A platforms. Please download the libraries and examples below: Code: Copy Sub Compress() As String Dim cpr As LZStringCompress cpr.Initialize Dim text As String = File.ReadString(File.DirApp & "\www", "testfile.txt") Dim cprText As String = cpr.Compress4Socket(text) Return cprText End Sub Code: Copy <script> async function getData() { const url = "http://127.0.0.1:51042/compress"; try { const response = await fetch(url); if (!response.ok) { throw new Error(`Response status: ${response.status}`); } var gzipsource = await response.text(); var puretext = LZString.decompressFromEncodedURIComponent(gzipsource); var decompress = document.getElementById('decompress'); decompress.innerHTML = puretext; } catch (error) { console.error(error.message); } } </script> Attachments java_lib.zip java_lib.zip 12.2 KB · Views: 403 Example_Server_Client.zip Example_Server_Client.zip 8.6 KB · Views: 435 b4j_lib.zip b4j_lib.zip 1.6 KB · Views: 377 b4a_lib.zip b4a_lib.zip 1.6 KB · Views: 390 javascript_lib.zip javascript_lib.zip 1.7 KB · Views: 393 Click to expand...
LZStringCompress, the method compress and decompress data through sockets LZStringCompress is a String encoding library, helping to speed up communication between the server and applications such as Android and Webapp faster and with a certain level of security. Instead of string communication which will cause data insecurity, using LZStringCompress will help improve the speed of your applications in case of large text volumes. LZStringCompress is currently a wrapper for Javascript, B4J, B4A platforms. Please download the libraries and examples below: Code: Copy Sub Compress() As String Dim cpr As LZStringCompress cpr.Initialize Dim text As String = File.ReadString(File.DirApp & "\www", "testfile.txt") Dim cprText As String = cpr.Compress4Socket(text) Return cprText End Sub Code: Copy <script> async function getData() { const url = "http://127.0.0.1:51042/compress"; try { const response = await fetch(url); if (!response.ok) { throw new Error(`Response status: ${response.status}`); } var gzipsource = await response.text(); var puretext = LZString.decompressFromEncodedURIComponent(gzipsource); var decompress = document.getElementById('decompress'); decompress.innerHTML = puretext; } catch (error) { console.error(error.message); } } </script>