# Select Case is Case-Insensitive

**URL:** <https://forum.xojo.com/t/select-case-is-case-insensitive/52288>\
**Category:** General\
**Created:** [February 6, 2020, 5:51am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288 "2020-02-06T05:51:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [February 6, 2020, 5:51am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/1 "2020-02-06T05:51:21Z")

</div>

I’m pretty surprised after all these years to discover that

`Select Case s
Case "A"
  return "Capital"
Case "a"
  Return "Lower"
end Select`

returns “Capital” for s = “a”. Does anyone else consider this a bug? Not to mention ironic…

---

<div class="post-metadata">

**Author:** ![Norman\_Palardy](https://forum.xojo.com/user_avatar/forum.xojo.com/norman_palardy/32/169_2.png) [@Norman\_Palardy](https://forum.xojo.com/u/Norman_Palardy)\
**Post date:** [February 6, 2020, 5:57am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/2 "2020-02-06T05:57:22Z")

</div>

just like every other string comparison in Xojo is

```auto
if "a" = "A" then
  break
end if
```

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [February 6, 2020, 5:59am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/3 "2020-02-06T05:59:49Z")

</div>

[quote=474335:@Norman Palardy]just like every other string comparison in Xojo is  
[/quote]  
Amazing that I’ve never realized this in all my coding… or maybe knew once and forgot.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [February 6, 2020, 6:13am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/4 "2020-02-06T06:13:29Z")

</div>

```auto
select case 0
case s.Compare( "A", ComparisonOptions.CaseSensitive )
  return "Capital"
case s.Compare( "a", ComparisonOptions.CaseSensitive )
  return "Lower"
end select
```

If that helps.

---

<div class="post-metadata">

**Author:** ![Norman\_Palardy](https://forum.xojo.com/user_avatar/forum.xojo.com/norman_palardy/32/169_2.png) [@Norman\_Palardy](https://forum.xojo.com/u/Norman_Palardy)\
**Post date:** [February 6, 2020, 6:17am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/5 "2020-02-06T06:17:59Z")

</div>

If this is basically a String extension method that relies on the same code as strcomp then you can still have issues since case sensitive is a byte wise comparison and wont handle composed vs decomposed unicode

text, however, does

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [February 6, 2020, 6:22am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/6 "2020-02-06T06:22:39Z")

</div>

[quote=474338:@Norman Palardy]If this is basically a String extension method that relies on the same code as strcomp then you can still have issues since case sensitive is a byte wise comparison and wont handle composed vs decomposed unicode

text, however, does[/quote]  
Byte-wise would suit me fine, I don’t go for that newfangled unicode stuff 🙂

---

<div class="post-metadata">

**Author:** ![Norman\_Palardy](https://forum.xojo.com/user_avatar/forum.xojo.com/norman_palardy/32/169_2.png) [@Norman\_Palardy](https://forum.xojo.com/u/Norman_Palardy)\
**Post date:** [February 6, 2020, 6:26am UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/7 "2020-02-06T06:26:54Z")

</div>

a quick test suggest the extension method is doing the right thing when comparing two strings that are “the same utf-8 character” - one composed and one decomposed

so its not JUST byte wise

&ue4 is lower case made up of a single code point  
&u61 + &u308 is the decompoased version of that (lower case a + combining diaresis)

both appear as  
but they are different bytes

yet this code considers then “equal” - you do not hit the break point

```auto

Dim s1 As String = &ue4
Dim s2 As String = &u61 + &u308

If s1.Compare(s2, ComparisonOptions.CaseSensitive) <> 0 Then
  Break
End If
```

if you change &uE4 for &UC4 you get the capitalized version of and it DOES hit the break point - as you should expect

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:16pm UTC](https://forum.xojo.com/t/select-case-is-case-insensitive/52288/8 "2021-04-29T16:16:48Z")

</div>


