[Gambas-user] Unable to split string containing ascii characters

Titan Rain 07.rain at ...626...
Sun Jun 5 07:52:03 CEST 2011


I'm trying to split a response from a server that has been stored as a string. This response contains the ascii characters  as data field padding. I should mention the response can get quite long too. Over 500 characters easily. For example a response may look something like 3somestring65somestring9018900101. I get strange results such as empty positions in the returned array, or the entire string returned in the first and only position of the array when I try to split the string with  as part of the seperator. I would also like to mention the debugger cannot display these characters at all. Note screenshot 1 below.

I have seen the tip-of-the-day that states "If you want to manipulate UTF-8 string, you must use the methods of the String static class, which have the same name as their standard counterparts." however the static string class does not have a split function.

I have tried using:
Chr(&C0) & Chr(&80) <-- the chr codes for 
DConv <-- raises an error (unable to convert)
Conv <-- raises an error (unable to convert)
Asc
^$ <--- a suggested delimiter instead of the 

I tried to write a function to convert the entire string to ascii

PUBLIC FUNCTION C2A(StringToConvert AS String) AS String
  DIM converted AS String
  DIM i AS Integer
   FOR i = 0 TO Len(StringToConvert)
    converted = converted & "-" & Asc(StringToConvert, i)
   NEXT 
  RETURN converted
END

Then splitting the string with ascii values of the seperators. It fails miserably. (Screenshot2)

Am I missing something, or am I asking for too much?

Below are some screenshots to help convey my problem.
Screenshot1: http://img651.imageshack.us/img651/5374/debuggerb.png

Screenshot2: http://img6.imageshack.us/img6/8966/ascarray.png

Screenshot3: http://img541.imageshack.us/img541/1899/65ae.png

In the latter 2 screenshots you can see the array is quite long, over 1000 in one case, when in fact the 65À€ (or 192-128-54-53-192-128) only occurs 2 times in the entire string.

Ubuntu 10.10 32 bit
Gambas 2.21 (from the ubuntu repository)

Any help is GREATLY appreciated.




More information about the User mailing list