Some additional string library functions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
spikey
Addict
Addict
Posts: 810
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Some additional string library functions

Post by spikey »

#PB_String_InPlace for LCase and UCase
It would be useful to be able to LCase or UCase larger strings in place the same way that ReplaceString can.

FindString in a buffer
It would be useful to be able to supply a pointer argument to FindString's String$ parameter.

TCase or ICase
A New Function To Initial Capitalise A String

Thank you for consideration.
User avatar
jacdelad
Addict
Addict
Posts: 2106
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Some additional string library functions

Post by jacdelad »

Sorry, wrong thread...
Last edited by jacdelad on Wed Feb 25, 2026 9:36 am, edited 1 time in total.
Good morning, that's a nice tnetennba!

PureBasic 6.30/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/2*DX517, 164TB+82TB+28TB+2TB SSD
Raspi 400/500
User avatar
mk-soft
Always Here
Always Here
Posts: 6605
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Some additional string library functions

Post by mk-soft »

In version PB v6.40 Alpha there will be no string inplace. Has also been removed in ReplaceString.
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Axolotl
Addict
Addict
Posts: 944
Joined: Wed Dec 31, 2008 3:36 pm

Re: Some additional string library functions

Post by Axolotl »

Yes, that reminds me of something...

Extension of StringField() ... New Parameter => Mode

Code: Select all

Result$ = StringField(String$, Index, Delimiter$, Mode=#PB_StringField_None) 
; 
; All (new) Mode Constants 
;
; #PB_StringField_None        ; default, act like the old Version 
; #PB_StringField_NoCase      ; ... if Delimiter$ something like "Text"  (A=a) 
; #PB_StringField_CSV         ; eg. String$ = "Text", 128, "A Text Line ", 0 => returns "Text" or "128" or "A Test Line "
; #PB_StringField_Trim        ; eg. String$ = Field 1  | Field 2  |      => returns "Field 1" or "Field 2"
; 
; #PB_StringField_SkipSQuote  ; eg. String$ = 'Text', 'A "Text" Line, cool ',  => returns "Text" or "A "Test" Line, cool "
; #PB_StringField_SkipDQuote  ; eg. String$ = "Text", "A Text Line, cool ",    => returns "Text" or "A Test Line, cool "
New Funtions based on StringField() for Integer results ...

Code: Select all

Result = StringFieldInteger(String$, Index, Delimiter$, DefaultValue) 
Result = StringFieldRangeInteger(String$, Index, Delimiter$, DefaultValue, MinValue, MaxValue) 
Extension of FindString() ... New Constants for Mode

Code: Select all

Position = FindString(String$, StringToFind$ [, StartPosition [, Mode]]) 
;
;  Old Mode (existing) 
;           #PB_String_CaseSensitive  .. case sensitive search (a=a) (default).
;           #PB_String_NoCase         .. Case insensitive search (A=a).
;
;  New Mode (extended) 
;           #PB_String_SkipSQuotes ..   skip single quotation marks 
;           #PB_String_SkipDQuotes ..   skip double quotation marks 
;
; Example 
;   String$ => Procedure TraceOut(ErrCode, Message$="; No Error")  ; VOID .. displays the message in Trace-Monitor 
; 
    result = FindString(String$, ";", 1, #PB_String_SkipDQuotes) 
    ; result = 53 


Then I could finally retire my self-made faulty functions. :)
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
idle
Always Here
Always Here
Posts: 6229
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Some additional string library functions

Post by idle »

There is the utf16 module with 2 variants
it does Ucase Lcase and Titlecase inplace
https://github.com/idle-PB/UTF16/blob/main/UTF16.pb
User avatar
spikey
Addict
Addict
Posts: 810
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Some additional string library functions

Post by spikey »

mk-soft wrote: Wed Feb 25, 2026 9:27 am In version PB v6.40 Alpha there will be no string inplace. Has also been removed in ReplaceString.
I haven't downloaded that yet to be honest. In which case, it's a request to have it re-instated too then!
idle wrote: Wed Feb 25, 2026 9:13 pm There is the utf16 module ... t does Ucase Lcase and Titlecase inplace
Useful to know, thanks!
User avatar
idle
Always Here
Always Here
Posts: 6229
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Some additional string library functions

Post by idle »

spikey wrote: Wed Feb 25, 2026 9:17 pm
mk-soft wrote: Wed Feb 25, 2026 9:27 am In version PB v6.40 Alpha there will be no string inplace. Has also been removed in ReplaceString.
I haven't downloaded that yet to be honest. In which case, it's a request to have it re-instated too then!
idle wrote: Wed Feb 25, 2026 9:13 pm There is the utf16 module ... t does Ucase Lcase and Titlecase inplace
Useful to know, thanks!
They are large 5000 and 11000 loc for accent stripping version but it means you can support full unicode with simple or full casefolding string compares. And do left right mid on utf16 encoded strings.
Post Reply