.Split on 64-bit

  1. ‹ Older
  2. 3 months ago

    Kevin G

    May 15 Pre-Release Testers, Xojo Pro Gatesheed, England

    Hi Derk

    If you can 100% gaurantee that your data is valid UTF8 you might be able to use the B functions (SplitB / MidB / LeftB etc...).

    The string functions currently have lots of issues under 64 bit so fingers crossed they all get addressed in 2017r2

  3. James S

    May 16 Pre-Release Testers, Xojo Pro

    Ah, it’s broken for multibyte characters. But not for ascii. It’s like it actually is the splitB function. With a listbox and a button in the window If I do this it works fine:

    Listbox1.DeleteAllRows

    Dim s As String = "one;two;three;four;five"

    Dim t() As String = Split( s, ";")

    For Each u As String In t
    listbox1.AddRow( "(" + u + ")")
    next

    but if I do this then it’s broken:

    Listbox1.DeleteAllRows

    Dim s As String = "oné;two;three;four;five"

    Dim t() As String = Split( s, ";")

    For Each u As String In t
    listbox1.AddRow( "(" + u + ")")
    next

    That makes sense that I’m not seeing it, as all the data I’m testing with is probably UTF8, but no multi-byte characters. I think MOST of my use of it does not involve user inputted data, but rather re-parsing strings of known providence, but I will verify for sure because it would make it very hard to debug a strange problem with one of our French users for instance.

  4. Michael D

    May 18 Pre-Release Testers, Xojo Pro
    Edited 3 months ago by Michael D

    Current Known Issues
    Long Split/Join operations on String may have issues. If you do not need multibyte encodings, you can use
    SplitB. Otherwise, convert the String to Text and then use the Text methods to Split or Join.

    That's misleading: I've seen the bug with only a few kilobytes of text - which is not what I would consider "long". Super dangerous bug in my opinion and that feature should not have shipped in that state.

    The good news is that if your data is UTF8 then SplitB works fine.

  5. Michel B

    May 18 Pre-Release Testers, Xojo Pro

    As far as I understand, the bug does not show up for Text. So it is possible to have a workaround.

  6. Thomas R

    May 18 Europe, France, Besancon

    Yes, as workaround I did my own split method which transform the string in text and then split it. Just be aware that when transform a string into text, the string encoding must be know (define)

  7. Derk J

    May 18 Pre-Release Testers, Xojo Pro
    Edited 3 months ago by Derk J

    @Michel B As far as I understand, the bug does not show up for Text. So it is possible to have a workaround.

    I split on text not on a string. I didn't mention that just checked it.

  8. Michel B

    May 19 Pre-Release Testers, Xojo Pro
    Edited 3 months ago by Michel B

    @Derk J String was a csv string working when compiled on 32-bit (no changes made)

    @Derk J I split on text not on a string. I didn't mention that just checked it.

    Your first post was specifying string.

    So, you mean the issue presents with Text ?

  9. Beatrix W

    May 19 Pre-Release Testers Europe (Germany)

    Can't reproduce this. Only the debugger hangs when viewing a longer text property (200k). But the split looks okay.

  10. Derk J

    May 19 Pre-Release Testers, Xojo Pro
    Edited 3 months ago by Derk J

    @Michel B Your first post was specifying string.

    So, you mean the issue presents with Text ?

    Well yes. I had string in use, it didn't work.

    Dim Line As String
    Dim Fields() As String
    
    Fields = Line.Split(";") 'Doesn't work on 64-bit build (no error, just strange data, seems offset).

    Then i had this:

    Dim Fields() As Text
    Dim Field As String
    Fields = Line.Split(";")
    
    For each f As Text in Fields
    
    field = f
    system.debuglog("field: " + field)
    
    Next
    

    I had some offset output.. to one char, changed all to "As Text" And it gives 0-problems.

  11. Beatrix W

    May 19 Pre-Release Testers Europe (Germany)
    dim t as Text = TextArea1.Text.ToText
    dim s(-1) as text = t.Split("das")

    works fine.

  12. Thomas R

    May 19 Europe, France, Besancon

    I will be bad guy, but I think as Xojo know that Spilt doesn't work on 64-bit, it should display an alert.

  13. Dave S

    Jun 8 San Diego, California USA

    I'm still trying to wrap my head around the "why" between "string" and "text".... but for now it is what it is....

    That being said..... can anyone confirm or deny, that this would work to provide a "split" STRING (not 'text') result in both 32bit and 64bit compile? I just don't want to waste a few hours doing use cases if someone already has a definitive answer :)

    Public Function Split64(source as string,delimiter as string) as string()
      Return Split(source.ToText,delimiter)
    End Function

    Does JOIN has similar issue? or can I leave that code in my app As-Is?

  14. Simon B

    Jun 8 Europe (Wiltshire, UK)

    Dave

    Simple observation. The .ToText function will return a BadDataException if the string encoding is not there. Perhaps you should add an encoding line:

    Public Function Split64(source as string,delimiter as string) as string()
      source = DefineEncoding(source, Encodings.UTF8)
      Return Split(source.ToText,delimiter)
    End Function
  15. Dave S

    Jun 8 San Diego, California USA

    Good point..... they SHOULD be UTF-8 but probably better to be safe...

    current app has 57 Split operations sprinkled thru it... and I want to compile it for 64bit without having to upgrade Xojo from 2016r4.1 (since I am broke)

  16. Simon B

    Jun 8 Europe (Wiltshire, UK)
    Edited 3 months ago by Simon B

    For what it's worth I use Split a lot and I only compile for 64 bit now. I haven't had a problem but I like the idea of your function.

    There are two new Targets defined, Target32Bit and Target64Bit. Using these you can change the compile options to cope with both. I would also use the extends keyword.

    Public Function Split64(extends source as string,delimiter as string) as string()
      Dim lst() As String
      source = DefineEncoding(source, Encodings.UTF8)
    
      #if Target64Bit then
        lst = Split(source.ToText,delimiter)
      #else
        lst = source.Split(delimiter)
      #endif
    
      return lst
    End Function

    Now you can change all instances of Split to Split64.

  17. Dave S

    Jun 8 San Diego, California USA
    Edited 3 months ago by Dave S

    Split64 function should work with both 32 and 64 bit without the need for "target" I would think

    And I HOPE would work that same way for macOS vs Windows

    Since ultimately I want to have a 64bit version that works for both OS

  18. Beatrix W

    Jun 8 Pre-Release Testers Europe (Germany)
    Edited 3 months ago by Beatrix W

    I'm waiting to have this fixed because I can't do much testing of 64bit without split.

    Changing from string to text is super-high risk IMO.

  19. Dave S

    Jun 8 San Diego, California USA

    @Beatrix W I'm waiting to have this fixed because I can't do much testing of 64bit without split.

    Changing from string to text is super-high risk IMO.

    Why? (asking to be educated, not to argue)

    My financial situation does not allow me to wait

  20. Beatrix W

    Jun 8 Pre-Release Testers Europe (Germany)

    My data is highly encoding-sensitive. Having incorrect encodings is normal for my data.

    I played around with the new text type a while ago and it took me only a couple of minutes to run into the BadDataException (something like that). And when having little surprises like this one here Feedback Case #48050 I think we will have lots of fun with both 64bit and the text type. This changes fundamental behavior which we have relied on for a long time. It doesn't matter what is correct or what is better.

  21. 2 months ago

    Thomas R

    Jun 9 Europe, France, Besancon
    Public Function Split64(source as string,delimiter as string) as string()
      Return Split(source.ToText,delimiter)
    End Function

    doesn't work for me.
    It's longer, but I do :

    Dim CeTabTxt(-1) as Text ' Les fonctions  Split et Join  ne fonctionnent pas (ou mal) en Build 64-bit
    Dim iNbre, Fin_iNbre as Int16 ' Ces méthodes fonctionnent mais sont plus lentes
    Dim CeTabStr(-1) as String
    
    CeTabTxt = CeText.ToText.Split(CeSep.ToText)
    Fin_iNbre = CeTabTxt.Ubound
    ' MsgBox "NbElts de MySplit(" + CeText + ", " + CeSep + ") = " + str(Fin_iNbre)
    For iNbre = 0 to Fin_iNbre
      CeTabStr.Append CeTabTxt(iNbre) ' .ToString
    Next iNbre
    
    Return CeTabStr ' On retourne un Tableau de String, Return Type : String()

    In one of my program I use characters like :
    WinMain.TabSymb = Array("◊", "•", "#", "?", "¿", "∆", "+", "-", "≠", "<—>", "—>", "<—", "—X", "X—", "ƒ", "»")
    which works with my Method but not with yours.

    Then it seems Split (on string) works in 64-bit with ASCII characters only, your method works with "standard" other characters, but if we use "strange" characters ("◊", "¿", "∆",) it doesn't work.

or Sign Up to reply!