[Gambas-user] Boxed string question

Tobias Boege taboege at gmail.com
Wed Sep 11 00:41:01 CEST 2019


On Wed, 11 Sep 2019, Gianluigi wrote:
> Hi all,
> 
> why does this code not work and does not transform all words into
> String.UCaseFirst?
> Boxed string shouldn't be similar to the mid function?
> 
> Private Function ProperCase(value As String) As String
> 
>   For i As Integer = 0 To Len(value) - 1
>     If value[i] = " " Then String.Upper(value[i + 1])
>   Next
>   Return String.UCaseFirst(value)
> 
> End
> 

  - Len() should not be used when working with UTF-8 strings. Len() returns
    the length in bytes, not in characters, which is exactly the wrong thing
    for UTF-8 strings. Use String.Len() instead.

  - String.Upper() does not modify its argument, so the return value of it
    under that If is just thrown away.

And I have a question too: Since when can you use a string like an array?
Is that documented? At least it seems like it is a read-only array, which
complicates the solution to the second issue...

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list