Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Additional libraries, classes and official updates
Documentation Wiki Register Members List Windows Mobile Search Today's Posts Mark Forums Read

Additional libraries, classes and official updates Users contributed libraries, classes and official updates. This forum is open for licensed users only.

New StringUtils library

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-22-2010, 12:56 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 25,771
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default New StringUtils library

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
File Type: zip StringUtils.zip (19.1 KB, 427 views)
Reply With Quote
  #2 (permalink)  
Old 12-23-2010, 01:52 PM
JesseW's Avatar
Senior Member
 
Join Date: Oct 2008
Posts: 307
Default

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..

Thanks...
Reply With Quote
  #3 (permalink)  
Old 12-23-2010, 02:15 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 25,771
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You can achieve most or all of these features with the internal String and Regex methods.
Reply With Quote
  #4 (permalink)  
Old 12-12-2011, 09:59 PM
Basic4android Expert
 
Join Date: May 2008
Location: Lombardia, Italy
Posts: 820
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Erel,

would it be possible to extend this library by adding support for the StringEscapeUtils-library? If I understand it correctly, you would need to add this library and your relative wrapper-code with your library.

See this post:
java - How can I Decode string? - Stack Overflow

and this is the library:
StringEscapeUtils (Commons Lang 2.5 API)

Personally, I am particularly interested in escaping/unescaping HTML and XML.
__________________
rgds,
moster67

Last edited by moster67 : 12-12-2011 at 10:07 PM.
Reply With Quote
  #5 (permalink)  
Old 12-13-2011, 08:40 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 25,771
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

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.
Reply With Quote
  #6 (permalink)  
Old 12-13-2011, 09:13 AM
Basic4android Expert
 
Join Date: May 2008
Location: Lombardia, Italy
Posts: 820
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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 :

Code:
Greater-than sign    >      >
Thanks anyway.


Quote:
Originally Posted by Erel View Post
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.
__________________
rgds,
moster67
Reply With Quote
  #7 (permalink)  
Old 12-13-2011, 09:43 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 25,771
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Can you post an example of an encoded string and the decoded string?
Reply With Quote
  #8 (permalink)  
Old 12-13-2011, 11:18 AM
Basic4android Expert
 
Join Date: May 2008
Location: Lombardia, Italy
Posts: 820
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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:

Code:
Dim Reader As TextReader
reader.Initialize(HttpUtils.GetInputStream(posturl))

ChannelList.Initialize

Dim line As String
line = Reader.ReadLine

Do While line <> Null  
if line <> Null Then        
ChannelList.Add(line)
End If
line = Reader.ReadLine
Loop
Reader.Close

For i = 0 To channelList.Size -1
channelCode=channelList.Get(i)
'various code for parsing channelcode
loop
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:

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

PHP Code:
------->> 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.
__________________
rgds,
moster67
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Door library (Beta) - Special library Erel Official Updates 60 01-13-2011 11:23 AM
Merging Outlook library and Phone library Erel Official Updates 11 09-15-2010 09:22 AM
PhoneticAlgorithms Library (ex-StringComparison Library) moster67 Additional Libraries 10 11-11-2008 07:46 PM


All times are GMT. The time now is 09:18 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0