B4A Library New StringUtils library

Discussion in 'Additional libraries, classes and official updates' started by Erel, Dec 22, 2010.

  1. Erel

    Erel Administrator Staff Member Licensed User

    This library supports Base64 encoding / decoding, URL format encoding and also it includes the beloved LoadCSV and SaveCSV methods.

    Reference: Basic4android - StringUtils
    The table example was updated and it can now load and save tables with these methods.

    Attached Files:

  2. JesseW

    JesseW Active Member Licensed User

    Nice one. Many thanks... :)

    If your open to a suggestion, how about including delimited string functionality? It would be nice to have the ability to get the count of sub-strings, extract an individual sub-string (at a specific position), add a sub-string, replace a sub-string, remove a sub-string, find a sub-string and return it's position, split a delimited string into an array, join array elements into a delimited string, and set the delimiter char. Some of this functionality may exist already..

  3. Erel

    Erel Administrator Staff Member Licensed User

    You can achieve most or all of these features with the internal String and Regex methods.
  4. moster67

    moster67 Well-Known Member Licensed User

    Last edited: Dec 12, 2011
  5. Erel

    Erel Administrator Staff Member Licensed User

    I didn't want to include the Apache Commons library in StringUtils to avoid adding the Apache license.

    Did you try to use UrlEncode / Decode? It should be similar to XML encoding / decoding.
  6. moster67

    moster67 Well-Known Member Licensed User

    Yes, I tried URLEncode/Decode but it will not work. For XML it is not really a problem - I believe using the XML-parser will take care of the entities.

    The problem is more the HTML-entities (after getting a HTML-source) and showing the output correctly when working with strings.

    I will try to write my own wrapper-library and see how it goes. If I get stuck with the library, I guess I can simply write a code-module with all HTML-entities and their corresponding character-values (such as :

    Greater-than sign    >      >
    Thanks anyway.

  7. Erel

    Erel Administrator Staff Member Licensed User

    Can you post an example of an encoded string and the decoded string?
  8. moster67

    moster67 Well-Known Member Licensed User

    In this moment I can't connect to the source of the html-page but what happens is that I use a procedure similar to this one to download the html-source for successive parsing:

    Dim Reader As TextReader


    Dim line As String
    line = Reader.ReadLine

    Do While line <> Null  
    if line <> Null Then      
    End If
    line = Reader.ReadLine

    For i = 0 To channelList.Size -1
    'various code for parsing channelcode
    TextReader supports UTF8 encoding by default which should be OK. I know that I can use reader.Initialize2 and specify which encoding to use but I doubt this will help because in any case, I don't know beforehand which encoding-scheme is being used.

    In any case, using above code, for instance I get:

    -------&gt;&gtGeneralisti &lt;&lt;-------
    which should be:

    ------->> Generalisti <<-------
    Of course, the string parsed may contain other HTML-entities.

    That is why I thought something to handle the HTML-entities could be useful.

Share This Page