[Implemented] #PB_String_NoCase for FindString()
- zxtunes.com
- Enthusiast
- Posts: 375
- Joined: Wed Apr 23, 2008 7:51 am
- Location: Saint-Petersburg, Russia
- Contact:
[Implemented] #PB_String_NoCase for FindString()
Please add flag "#PB_String_NoCase" for FindString() function.
Code: Select all
FindString(LCase(S.s), LCase(S.s), 0)
FindString(S.s, S.s, 0, #PB_String_NoCase)
Add an space to selected line
+100
FindString is very handy when work with strings, but always when i use it i feeling #PB_String_NoCase is missing....
I use Lcase() too but of constraint !
@Trond
If you like shorter, then instead of:
You can use:
Now which one is shorter and faster? 
FindString is very handy when work with strings, but always when i use it i feeling #PB_String_NoCase is missing....
I use Lcase() too but of constraint !
@Trond
If you like shorter, then instead of:
Code: Select all
FindString(LCase(S.s), LCase(S.s), 0)
FindString(S.s, S.s, 0, #PB_String_NoCase)
Code: Select all
FindString(LCase(S.s), LCase(S.s), 0)
FindString(S.s, S.s, 0, 1)

- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
not really.
a #PB_String_NoCase would mean that one bit is ignored while comparing.
(capital letters have bit5 cleared, small have bit5 set, the rest is identical for both alphabets.)
using LCase means, having a Function running thru both full strings changing all chars to lower case.
additionally, since we dont change the origin string but creating a copy
we pass to the FindString function, we need additional memory to do so.
I think the first could be achieved with an even faster algorithm.
a #PB_String_NoCase would mean that one bit is ignored while comparing.
(capital letters have bit5 cleared, small have bit5 set, the rest is identical for both alphabets.)
using LCase means, having a Function running thru both full strings changing all chars to lower case.
additionally, since we dont change the origin string but creating a copy
we pass to the FindString function, we need additional memory to do so.
I think the first could be achieved with an even faster algorithm.
oh... and have a nice day.
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
This is true for characters A-Z and a-z, respectively. Maybe also for some special characters, but certainly not for all of them. Many languages have special characters, such as our funny German umlauts. And the situation is even different with Unicode.Kaeru Gaman wrote:a #PB_String_NoCase would mean that one bit is ignored while comparing.
(capital letters have bit5 cleared, small have bit5 set, the rest is identical for both alphabets.)
Of course, we want a case-insensitive FindString() function to be reliable also for special characters.
Regards, Little John
Sorry, but that would be a complete disaster, even in ascii mode. In Unicode mode it will be worse...Kaeru Gaman wrote:a #PB_String_NoCase would mean that one bit is ignored while comparing.
Code: Select all
; IDE: Plain text source code
; Compiler: ascii mode
Procedure.s CompareIgnoreBit6(S1.s, S2.s)
If Len(S1) <> Len(S2)
ProcedureReturn "wrong length"
EndIf
For I = 1 To Len(S1)
C1.c = Asc(Mid(S1, I, 1)) & %11011111
C2.c = Asc(Mid(S2, I, 1)) & %11011111
If C1 <> C2
ProcedureReturn "NOT equal at " + Str(I)
EndIf
Next
ProcedureReturn "equal"
EndProcedure
Debug CompareIgnoreBit6("ABCDEF", "abcdef")
Debug CompareIgnoreBit6("ABCDEF", "aBcDeF")
Debug CompareIgnoreBit6("ABCDEF", "MNBVDE")
Debug CompareIgnoreBit6("ABCDEF", "ABCVDE")
Debug "Everything was ok so far..."
Debug "----"
S1.s = "{8 × 2 ^ 10] Ÿ ß"
S2.s = "[8 ÷ 2 ~ 10} ¿ ÿ"
Debug S1
Debug S2
Debug CompareIgnoreBit6(S1, S2) + "!?!?!"