The problem is that on Android and Windows, I believe the string trimming methods already do that - they remove characters below a space. With Swift on iPadOS, strings are implemented in an incredibly different fashion, so while I have used the built-in capabilities to remove whitespace and newlines, it doesn't seem as straightforward to take a character from a string (which may be represented with multiple scalar values) and compare it against a space in an "integer-like" fashion. There may be a way to do this properly, but I'm worried about hacking together a solution that may have errors or unintended effects when dealing with characters like emojis. It may be something like
while str.count > 0 && str.charAt(0).isAscii && str.charAt(0).asciiValue < 32 {
str = str.substring(1)
}
or something to that effect, but I would need to do a lot of testing to verify this works in every situation first. I tested it with some simple cases and it does appear to work properly though.
Mike
while str.count > 0 && str.charAt(0).isAscii && str.charAt(0).asciiValue < 32 {
str = str.substring(1)
}
or something to that effect, but I would need to do a lot of testing to verify this works in every situation first. I tested it with some simple cases and it does appear to work properly though.
Mike