Page 8 of 8 FirstFirst ... 5678
Results 281 to 301 of 301

Thread: The 1001 questions about vbRichClient5 (2020-07-21)

  1. #281
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    You haven't created an instance of the cFSO object yet. Try:

    Code:
    New_c.FSO.FileExists(App.Path & "\Logo.png")
    Last edited by jpbro; Jan 19th, 2024 at 11:57 PM.

  2. #282
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Thank you @jpbro.

    I can use it after testing.
    QQ: 289778005

  3. #283
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by dreammanor View Post
    All of my desktop tools will be developed based on RC5, and I'll have a lot of questions to ask Olaf and other RC5 experts. In order not to disturb other people, I concentrated all my questions about RC5 in this thread.
    Quote Originally Posted by dreammanor View Post
    Olaf and other RC5 experts could pick up some valuable questions to answer and ignore the worthless questions.
    .. . ..
    .. . ..
    Quote Originally Posted by dreammanor View Post
    If someone else wants to ask questions about RC5 in my thread, I'll also put them in the list above. All questions about RC5 are welcome.


    Dear Olaf (DreamManor and other RC5 experts too),

    I would be extremely grateful if I can get answers to the following questions :

    Brief Scenario:
    I have an existing free app (downloadable from my website and thus already deployed in 1000s of end-users' systems). It uses many of Krool's invaluable controls. I am very much thinking of making use of your fabulous RC5 also in my app now, esp. your RC5's WebKitCairo. As of now, I will display some local web pages inside my app in some screens (using your WebKitCairo or WebKitCairoNewLibCurl). As I progress further, I will act upon events of the displayed local pages' buttons, canvas, etc. I will do most of the event handling within my app itself and show the results in the displayed local page's text area, etc. I might choose to show the results in some vb6 controls (TextBox, PictureBox, etc.) too in my app's screen. The idea is to try pushing(wherever possible) the UI design of my screens to html/css/javascript (since it has "loads" of advantages for me).

    Based on the above scenario, my questions are:

    1. Will the portions of my app using your RC5 (incl. my app's screens which avail your WebKitCairo or WebKitCairoNewLibCurl) work in Windows 11 also? If they will definitely work, without any issues whatsoever (for at least the next 5 years), great.

    2. This page - https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge/ - says that the "Internet Explorer 11" desktop application will be retired and go out of support on June 15, 2022, for certain versions of Windows 10.

    Will the above situation have any bearing at all on my app? Will the portions of my app, incl. the portions using your WebKitCairo or WebKitCairoNewLibCurl, continue to behave exactly as before in all OSes (Win7-to-Win11 would suffice if not WinXP-to-Win11), after 15-June-2022 also? If so (for at least the next 5 years), then again, great.

    3. If the portions of my app using your RC5, esp. the portions using your WebKitCairo or WebKitCairoNewLibCurl, will not work in Win11 (OR) if they will not work in one or more OSes after 15-June-2022, then, what is the best approach for me?


    • Well, as of now, I cannot straightaway start using your RC6 in my app (even though I understand that the WebView2 methodology will definitely work in Win11 and that the supported OSes are Win7-to-Win11 for WebView2). This is because of the large size of the 'WebView2 Runtime' installer (more than 100 MB) which is required to be installed in end-users' systems by Microsoft. I have read all the end-user deployment options given by Microsoft (https://docs.microsoft.com/en-us/mic...s/distribution) but none of them will be viable in the case of 'all of' my end users (since all may not have the facility to download large files; since all may not have hard disks with sufficient capacity to allow installation of such large runtimes which may occupy lot of space in their hard disks; also some users, even if they have the required facilities, just do not like to download/install large executables since they feel it may affect their systems). So, using RC6 (which contains WebView2Loader) in my app is not feasible, as of now.


    4. If all portions (let me collectively call them 'XYZ') of my app using your RC5, incl. the portions availing your WebKitCairo or WebKitCairoNewLibCurl, will definitely work in all OSes including Windows 11, without any issues (for at least the next 3 years, if not 5), then, going forward, I might love to have one more version of my app where 'XYZ' uses your RC6 instead of RC5 so that users who do not mind installing the 'WebView2' runtime can use that version of my app. In such a case, I wish to know whether my RC5-involving codes (esp. the ones involving your WebkitCairo or WebKitCairoNewLicCurl) be easily portable to RC6 (with no or minimal code changes) OR will I have to recode most or all of my RC5 code?

    5. Are there any WebKitCairo tutorials, examples, demos? If so, kindly let me know the web links for them. I was not able to find them so far. I was able to find only the following tutorials so far - RC5cairoTutorial.zip, RC5formsTutorial.zip, RC5WidgetsTutorials.zip and CairoTutorial-master.zip.

    6. In the case of RC6 also, are there any WebView2 tutorials?

    Expecting your answers on the above, so that I can assuredly start using your RC5 (or RC6, if that is the ideal/only choice, going forward) in my app.

    Kind regards.

    NOTE:
    Though I had a single QUOTE block only at the top of my message, after I submitted/saved my reply/changes, the single QUOTE block automatically turned into multiple QUOTE blocks.
    Don't know why. I edited my message 2 to 3 times to make it a single QUOTE block again (at the top) but same thing happened in the final output (it changed to multiple QUOTE blocks). So, I am leaving the 3 QUOTE blocks (at the top) as they are.
    Last edited by softv; Sep 11th, 2021 at 06:18 AM.

  4. #284
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: The 1001 questions about vbRichClient5 (2019-05-26)

    I see that cActiveScript can execute JavaScript code. But can it do so if the javascript code references another library?
    I tried referencing the library in the first line of the script (ex.
    Code:
    const path = require('path');
    ) but that doesn't seem to work.

  5. #285
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: The 1001 questions about vbRichClient5 (2019-05-26)

    Quote Originally Posted by AAraya View Post
    I see that cActiveScript can execute JavaScript code. But can it do so if the javascript code references another library?
    I tried referencing the library in the first line of the script (ex.
    Code:
    const path = require('path');
    ) but that doesn't seem to work.
    ES6 modules are neither supported by "JScript" nor are they via the also supported "JScript9" initiator-string.

    So, I'd rely on the strength of both interpreter-engines, which is to use COM-Dlls or -Objects (instead of "modules").

    Code:
    Option Explicit
    
    Private WithEvents JS9 As cActiveScript
    
    Private Sub Form_Load()
      Set JS9 = New_c.ActiveScript("JScript9", True, False) 'this adds the COM-Objects New_c and Cairo already into the js-context
          JS9.AddObject "console", Me 'here we add a third COM-Object (the Form itself)
          
      With New_c.StringBuilder
          .AddNL "var D = new ActiveXObject('Scripting.Dictionary')" 'and here the 4th COM-Object (the MS-Scripting.Dictionary) this time via js-code itself
          
          'COM-Object access (via variables D, as well as New_c and Cairo)
          .AddNL "D.Add('SQLite-Version', New_c.Connection().Version())"
          .AddNL "D.Add('Cairo-Version', Cairo.Version)"
          
          .AddNL "console.log( D('SQLite-Version') )" 'and here two COM-Objects are addressed, the console(Form) with its Public Log-Method
          .AddNL "console.log( D('Cairo-Version') )"  '...printing out the Values behind COM-Object D("SomeKey")
          JS9.AddCode .ToString
      End With
    End Sub
     
    Public Sub Log(ByVal Text)
      Debug.Print Text
    End Sub
    Olaf

  6. #286
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-02-08)

    Quote Originally Posted by Schmidt View Post
    Nice...

    FWIW, here's a performance-improvement for the ActiveScript-JSCode based replacements
    (which also corrects a few errors in the reg-expressions):

    Code:
        With New_c.StringBuilder 
           .AppendNL "'use strict';"
           .AppendNL "var regCmtSngLine1 = /(^\/\/.*?(\r|\n))/gm ;"
           .AppendNL "var regCmtSngLine2 = /(?!([""']([^\\[""']]*).*[""'])).(\/\/.*?(\r|\n))/g ;"
           .AppendNL "var regCmtMultiLine = /(\/\*[\w\'\s\r\n\*]*\*\/)/g ;"
     
           .AppendNL "var regLet = /^\s*[\{\(]*let \b/gm ;"
           .AppendNL "var regEmptyLines = /^\s*[\r\n]/gm ;"
     
           .AppendNL "function CompressJavaScript(code){"
           .AppendNL "  return code"
           .AppendNL "         .replace(regCmtSngLine1,'')"
           .AppendNL "         .replace(regCmtSngLine2,'')"
           .AppendNL "         .replace(regCmtMultiLine,'')"
           .AppendNL "         .replace(regLet,'var ')"
           .AppendNL "         .replace(regEmptyLines,'')"
           .AppendNL "}"
           mSC.AddCode .ToString
        End With
    With these changes it is now faster than the (VB)Scripting-Regex-Code -
    (also note, that "JScript" works - surprisingly - a bit faster than the newer "JScript9" engine).

    Olaf
    Dear Olaf,

    First of all, I wish you a Very Happy New Year. Its always a great feeling, wishing an extremely magnanimous soul like you, as my heart wells up with gratitude. And, I take this opportunity to wish a Happy New Year to all the great masters and experts of our VbForums through whom countless many (which includes me also naturally) have got benefited and in turn passed on those benefits, in one way or other, to a further 'countless many' of the society, like a positive chain reaction.

    Well, the following are in reference to this post of mine - https://www.vbforums.com/showthread....=1#post5627131 - Post #51
    --
    1. Is there any way of using ActiveScript to specify a language which would allow me to use LookBehinds in regular expressions?

    2. ActiveScript was able to accept 'Chakra' as language. It did not seem to accept 'V8' as language though, as the language got automatically set as 'Jscript9' by your ActiveScript (as it was the case with any other random string I passed to it as language).

    3. I tried WV.jsRun too, just to see what happens. It accepts lookbehinds in regex patterns, obviously. But, it was quite slow. May be it can be done in a way to make it run fast but I did not know how. Using jsRunAsync did not seem to be the right way to effect faster regex operations.
    --

    So, is there any way at all, as of today, either through ActiveScript or WV or any other technology, to use a flavour of JS, which, like pcre2, can effect regex operations with all the allowed specifications (incl. Lookbehinds, groups, etc. [since the 2018 ECMAScript specs, as I get to understand from the net]) and also effect such regex operations as fast as wonderful JpBro's Pcr wrapper (OR) your ActiveScript Js (OR) VB RegEx.

    Thanks in tons, once again, for all your free offerings to the society.

    Kind Regards.

    Edit-1:
    Just now, after posting the above, I checked out my referred post in JpBro's thread and I notice a new reply therein, from you!!!, Olaf. I will now go and read that fully.

    Edit-2:
    First of all, as ever, thanks a lot for your reply in JpBro's thread. I had not made that init/reinit optimisation (as in your code) in 'pcrTest' either. So, I started to make them (so that my future benchmarking will be on even scales). And, "to whatever level I could" do^ the optimisation, with my limited knowledge, and "to whatever level I have tested so far", as per my initial findings, I see a dramatic increase in processing speed in JpBro's pcrTest, w.r.t the non-English database. Once I have done a thorough testing for both non-English and English databases, I will share my results in JpBro's thread. At that time, I would request you to kindly help me know (if possible and if and when you find time) the ideal manner in which the pcrTest code shall be, so that it will carry the highest optimisation. In case my initial findings prove later to be not correct, I shall inform that also here. Thank you soooooo much once again for taking time, even amidst your hectic schedules, to give such clear-cut code snippets. Remaining in all humbleness, as always.
    (^) I dont know whether I have handled the memory free-ings correctly. That's one more reason for which I have requested your kind help above. I wanted to post pcrTest code in my last reply in JpBro's thread itself but forgot.

    Edit-3: The weblink I gave to "my post in JpBro's thread" was not working correctly because of the closing bracket getting added to the link, upon clicking it. So, I removed the enclosing brackets now. Also, mentioned the post no.

    Last edited by softv; Jan 1st, 2024 at 03:50 PM.

  7. #287
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Is this thread strictly related to RC5 only or I can ask questions related to RC6 also?

    If I can ask questions related to RC6 also, then can I ask questions related to everything RC6 (on sqlite, on cairo, on modules like 'FSO, Crypt etc.', on widgets, etc. except on webview2)? I am not including webview2 since I am aware of the separate thread for it (started by Olaf) and I have always posted questions related to webview2 therein only.

    Any guidance on the above from anybody most welcome.

    Kind Regards.
    Love is God. God is Love. As Ever, All Glory and Thanks to the Lord Almighty Only, Forever...

    "You say grace before meals. All right. But I say grace before the concert and the opera, and grace before the play and pantomime, and grace before I open a book, and grace before sketching, painting, swimming, fencing, boxing, walking, playing, dancing and grace before I dip the pen in the ink." - G. K. Chesterton

  8. #288
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by softv View Post
    Is this thread strictly related to RC5 only or I can ask questions related to RC6 also?
    Since user-code written for RC5 runs with an RC6-reference as well,
    I don't see any problems with asking any RichClient-related questions here...

    Alternatively, opening specific new threads here, when prefixed with [RC6] in the title,
    should also work (without throwing anybody off).

    RC6 plays in the same "ballpark" as other "big COM-reference-checkins for VB6" (like "MS ADO" for example).

    Olaf

  9. #289
    Addicted Member jj2007's Avatar
    Join Date
    Dec 2015
    Posts
    205

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by Schmidt View Post
    (like "MS ADO" for example)
    Olaf, I just spent some weeks (!) fighting with MS ADO. It's a horrible mess, with e.g. different arg counts for OpenSchema for C++, VB, C#, ...but in the end I got this working (pseudocode):
    Code:
      .if !OpenAdo(CL$())	; command line, can be xls, xlsx, mdb or dbf files
    	For_ n=0 To OpenAdo(0)-1	; 0=first sheet
    		PrintLine AdoTable$(n, 5)  ; row n, column 5 (tab-delimited format)
    	Next
    	PrintLine "bye" 
      .endif
    Back to RichEdit: has anybody noticed that on Win 10, you get artifacts on screen, tiny little vertical lines?
    Last edited by jj2007; Jan 18th, 2024 at 04:58 AM.

  10. #290
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by Schmidt View Post
    Since user-code written for RC5 runs with an RC6-reference as well,
    I don't see any problems with asking any RichClient-related questions here...

    Alternatively, opening specific new threads here, when prefixed with [RC6] in the title,
    should also work (without throwing anybody off).

    RC6 plays in the same "ballpark" as other "big COM-reference-checkins for VB6" (like "MS ADO" for example).

    Olaf
    Thanks as always, olaf.

    Following is a RC6-related question.

    It would be helpful, Olaf, if you can kindly let me know what is going wrong in the following process:
    --
    1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
    2. I use b = str to save that string to b()
    3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
    4. Then I save b to a string (encryptedStr = b)
    5. Then I save encryptedStr in a TEXT field in a sqlite database
    --

    In above process, in some cases (with regard to the strings stored in str), encryptedStr is stored in Sqlite as it is. Sometimes, not.

    For e.g. if str is changed to str = "abcdefghijklmnopqrstuvwxyz':" (just the 'z' alone added), Sqlite does not store encryptedStr the same way as it is in VB6.

    Of course, I am able to store b() as blob in Sqlite but I wish to know how to store encryptedStr itself in a TEXT field. In whatever I have come to understand in my limited knowledge, String and Bytes are interchangeable in VB6. So, I thought there should not be any problem for Sqlite. So, what is going wrong above? What mistake am I doing? Have I to use StrConv. If so, how?

    // Alternatively, opening specific new threads here, ... .. . //
    In my very humble opinion is, if there is just "one single thread" (just ONE and only one) in our forum where ALL sorts of questions can be asked to you (whether it be in VB6 or RC5 or RC6), that will be 'extremely' immensely useful for a person like me (and all others who have the same wish in their mind). I kindly request yourself to start such a thread, if at all you deem it fit. May be the thread's title/topic can be "Olaf - ANY questions related to VB6, RC5 or RC6". In case there are any other areas which I have missed (apart from VB6, RC5 and RC6) which are also permissible (by the forum mods) to be asked in that thread, I kindly request you to add them too in the thread title/topic. If you think such a single thread will be a burden of sorts to you (amidst your already hectic schedules), then no problems. Kindly ignore this request of mine. On the other hand, if you think my idea is good, then great. I believe the other gurus/experts will also chip in to help (in that thread), whenever they can, esp. when you are not in a position (for whatever reasons) to attend to our questions in time.

    In all humbleness.

    Ever in utmost gratitude to your selfless service.

    Kind Regards.

    Edit-1: I forgot to mention the way I stored the data in the text field. It was as follows:
    --
    Set localCnn = New cConnection
    localCnn.CreateNewDB
    localCnn.ExecCmd ("CREATE TABLE S (str TEXT NOT NULL)")
    Set localCmd = localCnn.CreateCommand("Insert Into S Values(@str)")
    With localCmd
    .SetText !str, encryptedStr
    .Execute
    End With
    localCnn.CopyDatabase dbFileLocal
    --

    Edit-2:
    --
    On further exploring with 4 different strings, it seemed like if there are bytes in the encryptedStr holding values in the 'Surrogates range' or in some specific range of the 'PUA range' of the Unicode block, it is causing problems while storing those strings in Sqlite DB. Well, I am not having time to explore further more. And, probably my exploration with the 4 strings is completely off the track too. So, let me await your reply now, when you find time, pointing out to the mistake(s) done by me at my end. Thanks in advance.
    --
    Last edited by softv; Jan 18th, 2024 at 10:49 AM.
    Love is God. God is Love. As Ever, All Glory and Thanks to the Lord Almighty Only, Forever...

    "You say grace before meals. All right. But I say grace before the concert and the opera, and grace before the play and pantomime, and grace before I open a book, and grace before sketching, painting, swimming, fencing, boxing, walking, playing, dancing and grace before I dip the pen in the ink." - G. K. Chesterton

  11. #291
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by softv View Post
    1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
    2. I use b = str to save that string to b()
    3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
    4. Then I save b to a string (encryptedStr = b)
    5. Then I save encryptedStr in a TEXT field in a sqlite database
    What's wrong in the above steps, is #4.

    As soon as you leave "Unicode-String-Space" - and enter "Raw-Byte-Space"
    (e.g. after applying an encryption-algo on the string-bytes) -
    you should "stay in that universe of raw-bytes" and not treat such raw-bytes like string-content.

    Here's an example:
    Code:
      Const Msg As String = "abcdefghijklmnopqrstuvwxyz':"
      Const Pwd As String = "SomePassPhrase"
      
      Dim M As cMemDB, B() As Byte
      Set M = New_c.MemDB
          M.Exec "CREATE TABLE T(EncStr BLOB)" 'encrypted Strings belong into properly typed Blob-Fields
          
      B = New_c.Crypt.VBStringToUTF8(Msg) 'to ensure a usually smaller B (compared to a direct 1:1 UTF16-copy like B=Msg)
      'B now contains the UTF8-encoded String-Bytes
      New_c.Crypt.AESEncrypt B, Pwd 'inplace-encryption on the Bytes of B
      'B now contains encrypted "raw-bytes" (which neither follow UTF16- nor UTF8-encoding conventions anymore)
     
      M.ExecCmd "Insert Into T(EncStr) Values(?)", B 'store B in the Blob-Field of Table T as a new record
      B = M.GetRs("Select EncStr From T").Fields("EncStr").Value 'here we get B back from the first record of the Rs
      New_c.Crypt.AESDecrypt B, Pwd 'inplace-decryption on the just retrieved B-Blob
      Debug.Print New_c.Crypt.UTF8ToVBString(B) 'back-conversion of the decrypted (now UTF8 again) B-Bytes into an UTF16-VBString
    Olaf

  12. #292
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,324

    Red face Re: The 1001 questions about vbRichClient5 (2020-07-21)

    He said he didn't want to use a BLOB field in the database but use a TEXT field instead!
    In this case I think one solution would be to encode the byte array to Base64, probably RC6 should have such as function as well...

  13. #293
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by Schmidt View Post
    What's wrong in the above steps, is #4.

    As soon as you leave "Unicode-String-Space" - and enter "Raw-Byte-Space"
    (e.g. after applying an encryption-algo on the string-bytes) -
    you should "stay in that universe of raw-bytes" and not treat such raw-bytes like string-content.

    Here's an example: ... .. .
    ... 'to ensure a usually smaller B
    .. (which neither follow UTF16- nor UTF8-encoding conventions anymore)
    .
    Olaf
    Thanks a TON, as always, Olaf.

    Learnt a lot (incl. the cMemDB tip). Thank you so much.

    Kind Regards.
    Last edited by softv; Jan 18th, 2024 at 11:41 AM.
    Love is God. God is Love. As Ever, All Glory and Thanks to the Lord Almighty Only, Forever...

    "You say grace before meals. All right. But I say grace before the concert and the opera, and grace before the play and pantomime, and grace before I open a book, and grace before sketching, painting, swimming, fencing, boxing, walking, playing, dancing and grace before I dip the pen in the ink." - G. K. Chesterton

  14. #294
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by VanGoghGaming View Post
    He said he didn't want to use a BLOB field in the database but use a TEXT field instead!
    In this case I think one solution would be to encode the byte array to Base64, probably RC6 should have such as function as well...
    Sure, that would be one way, to keep the DB-Tables Field-Type as Text -
    (at the cost of increasing the "occupied DB-StorageSpace" by 33% in that Table-Field).

    Cannot see any advantage, to simply re-typing that Column to a Blob-Type
    (since "Text-Searching" or any other DB-String-Ops on that Field are not possible anyways, when encrypted).

    Another (easier) way would be, to encrypt the whole SQLite-DB with a passphrase.

    Olaf

  15. #295
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Originally Posted by softv
    1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
    2. I use b = str to save that string to b()
    3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
    4. Then I save b to a string (encryptedStr = b)
    5. Then I save encryptedStr in a TEXT field in a sqlite database


    Quote Originally Posted by Schmidt View Post
    What's wrong in the above steps, is #4.

    As soon as you leave "Unicode-String-Space" - and enter "Raw-Byte-Space"
    (e.g. after applying an encryption-algo on the string-bytes) -
    you should "stay in that universe of raw-bytes" and not treat such raw-bytes like string-content.
    Olaf
    Just one thing I wish to understand regarding the above, dear olaf.

    After step 4, if I do the following within VB6, 's' gets printed correctly for any string stored in 'str' initially. So, what is the basics surrounding this? May be I am not clear about those basics. And that's why I am asking this question. So, when possible, kindly educate me.
    --
    Dim bAgain() As Byte
    Dim s As String
    bAgain = encryptedStr
    New_c.Crypt.AESDecrypt bAgain, Pwd
    s = bAgain
    Debug.Print s
    --

    Kind Regards.
    Love is God. God is Love. As Ever, All Glory and Thanks to the Lord Almighty Only, Forever...

    "You say grace before meals. All right. But I say grace before the concert and the opera, and grace before the play and pantomime, and grace before I open a book, and grace before sketching, painting, swimming, fencing, boxing, walking, playing, dancing and grace before I dip the pen in the ink." - G. K. Chesterton

  16. #296
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by softv View Post
    Originally Posted by softv
    1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
    2. I use b = str to save that string to b()
    3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
    4. Then I save b to a string (encryptedStr = b)
    5. Then I save encryptedStr in a TEXT field in a sqlite database


    After step 4, if I do the following within VB6, 's' gets printed correctly for any string stored in 'str' initially. So, what is the basics surrounding this? May be I am not clear about those basics. And that's why I am asking this question. So, when possible, kindly educate me.
    --
    Dim bAgain() As Byte
    Dim s As String
    bAgain = encryptedStr
    New_c.Crypt.AESDecrypt bAgain, Pwd
    s = bAgain
    Debug.Print s
    --
    Your encryptedStr-Variable above contains bytes, which - after prior encryption - are not:
    "WChar-Bytes, which follow UTF16-rules" anymore...

    ...and as such, should not be fed e.g. into any Text-expecting or Text-Conversion-routine
    like e.g. the WideCharToMultibyte-API (to convert them to UTF-8-text for SQLite-storage)

    Your example above works, because the direct assignments (ByteArray=VBString and vice versa)
    just make 1:1 data-copies of the content (without interpreting, or converting it in any way).

    So in short, the VBString-Type is able to store "arbitrary byte-sequences" (which are not WChars) -
    but you should be aware in such cases, that they do not contain proper UTF16-Text and treat them as "plain byte-buffers" then.

    Olaf

  17. #297
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Its fully clear now. Thanks a lot, olaf. It helps a lot when the basics become clear.

    It is really so kind of you to take the extra mile, for my sake, and provide additional explanatory statements like "...and as such, should not be fed e.g. into any Text-expecting or Text-Conversion-routine like ... .. .", "without interpreting, or converting it in any way" and "in short, the VBString-Type is able to store 'arbitrary byte-sequences' (which are not WChars) but ... .. ." . These helped me so much, to get that perfect clarity in my mind. Thanks a lot, once again.

    Kind Regards.
    Love is God. God is Love. As Ever, All Glory and Thanks to the Lord Almighty Only, Forever...

    "You say grace before meals. All right. But I say grace before the concert and the opera, and grace before the play and pantomime, and grace before I open a book, and grace before sketching, painting, swimming, fencing, boxing, walking, playing, dancing and grace before I dip the pen in the ink." - G. K. Chesterton

  18. #298
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    This post is RC6-related.

    Dear olaf,

    Thanks a TON for the AppendText function in FSO. I have always wondered why a simple function to append text to text files did not exist straightaway. So, thanks a lot.

    By the way, both in WriteTextContent and AppendTextContent, I am able to see option for writing to utf-8 but not for writing to UTF-16 file. Sorry if I am missing any such option. Kindly let me know how to write to UTF-16 encoded text files.

    I tried WriteByteContent to see whether it can create UTF-16 encoded text files but did not succeed. In any case, in which specific scenarios (if any) WriteByteContent and ReadByteContent will be used while reading contents of text files?

    And, as far as I see, ReadTextContent returns Unicode strings from both utf8 and utf16 files. There is no need to specify any extra option. Is my understanding correct? And, what is the "IsRaw16bit" option for?

    Kind regards.
    Love is God. God is Love. As Ever, All Glory and Thanks to the Lord Almighty Only, Forever...

    "You say grace before meals. All right. But I say grace before the concert and the opera, and grace before the play and pantomime, and grace before I open a book, and grace before sketching, painting, swimming, fencing, boxing, walking, playing, dancing and grace before I dip the pen in the ink." - G. K. Chesterton

  19. #299
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by softv View Post
    ... both in WriteTextContent and AppendTextContent, I am able to see option for writing to utf-8 but not for writing to UTF-16 file.
    UTF-8 is kind of standard for TextContent-transport or -storage (whilst UTF16 is not).
    That's the reason behind it...

    If you want to append UTF16, you will have to do it by hand:
    Code:
      B = SomeVBString 'direct ByteArray-conversion of UTF16 into B
      With New_c.FSO.OpenFileStream(FileName, STRM_WRITE Or STRM_SHARE_DENY_NONE, True)
         .SetPosition 0, STRM_SeekFromEnd 'move to the end of the file...
         .WriteFromByteArr B           ' ...and write the byte contents
      End With
    Quote Originally Posted by softv View Post
    ...as far as I see, ReadTextContent returns Unicode strings from both utf8 and utf16 files.
    There is no need to specify any extra option. Is my understanding correct? And, what is the "IsRaw16bit" option for?
    The Method tries to "do things right" (when the Optional Params are left at their defaults) -
    and it will get help from "the files themselves", in case they have "leading UTF8 or UTF16-BOMS".

    As soon as you change the Opt-Params from their defaults (as e.g. setting IsRaw16bit = True),
    you're "forcing" the routine to behave in a certain way...(e.g. when an UTF16-File does not have a BOM).

    Since you're asking a lot of questions related to UTF16-storage -
    what's the reason you seem to prefer that text-encoding over UTF8?

    Olaf

  20. #300
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Dear olaf,

    // If you want to append UTF16, you will have to do it by hand //
    Thanks a lot. I shall try that soon.

    Actually, I process both utf-8 and utf-16 files. So, I was looking for utf-16 options too. Any chances, in the future? In fact, the options' defaults not being to utf-8 was somewhat of a surprise to me. You can kindly educate me on the same too as to why they are so.

    Coming back to utf-16, your question on it prompted me to do some fresh testing at my end, now that I have started using RC6's FSO.

    Around a 9mb Unicode file (utf-16le, carrying fully non-English characters) saved to utf8 and tested with both my 'existing' routine and RC6's gave the following results, while reading the files. Just thought of sharing with you.
    --
    49.32msec existing utf8 4560738
    53.09msec existing utf8-bom 4560738
    14.38msec existing utf16-bom 4560738
    --
    34.39msec RC6 utf8 11783558**
    37.56msec RC6 utf8-bom 4560738
    10.74msec RC6 utf16-bom 4560738
    --
    Note: 4560738 is the stored string's length

    (**) this was with default settings.
    With "New_c.FSO.ReadTextContent(fname, , CP_UTF8)", the results were:
    --
    46.21msec RC6 utf8 4560738
    --

    I find RC6 as 1000s of beautiful/beauty-filled tools/apps in one very "fast, compact & robust" framework. I Simply Love it. Thanks a TON, again.

    Kind Regards.
    Last edited by softv; Jan 19th, 2024 at 11:00 PM.
    Love is God. God is Love. As Ever, All Glory and Thanks to the Lord Almighty Only, Forever...

    "You say grace before meals. All right. But I say grace before the concert and the opera, and grace before the play and pantomime, and grace before I open a book, and grace before sketching, painting, swimming, fencing, boxing, walking, playing, dancing and grace before I dip the pen in the ink." - G. K. Chesterton

  21. #301
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: The 1001 questions about vbRichClient5 (2020-07-21)

    Quote Originally Posted by softv View Post
    Actually, I process both utf-8 and utf-16 files.
    Working with utf16-files is a bit unusual to me...
    (am writing all kind of LOB-Apps for about 30 years now, and encountering such files in daily work, is extremely rare).

    Whilst utf-8 is the text-format I encounter daily (in text-files, in web-downloads, in JSON, in XML-files, etc.)

    No idea, why you'd want to produce utf16-files "willingly" yourself -
    because "chances are very high", that e.g. some csv-file you produced in utf16(LE) format,
    as e.g. "WebExports" from your DeskTop-App to some WebServer "not in your responsibility" -
    will throw off the "PHP-Web-Admin on the other side" in a big way.

    Quote Originally Posted by softv View Post
    So, I was looking for utf-16 options too.
    If it's speed you want (against local SSDs, avoiding Extra-Multibyte-conversion-API-calls),
    there's already enough support IMO, via:
    - B = S: New_C.FSO.WriteByteContent(FileName, B) 'just two instructions, to produce a "raw 16Bit-LE-file"
    - S = New_C.FSO.ReadTextContent(FileName, True) '<- with IsRaw16Bit=True, one instruction is needed to read back into a VBString

    Quote Originally Posted by softv View Post
    ...the options' defaults not being to utf-8 was somewhat of a surprise to me
    Was trying to be compatible to VBs (and VBScript-FSO) Text-routines by default -
    writing and reading ANSI in the default-locale when no Params were given in ReadTextContent/WriteTextContent.

    If BOMs are detected (in Read-direction), all optional Params are ignored (over-ruled by the BOMs).

    Olaf

Page 8 of 8 FirstFirst ... 5678

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width