github.com/blend/go-sdk@v1.20220411.3/stringutil/equals_caseless.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package stringutil
     9  
    10  // EqualsCaseless compares two strings regardless of case.
    11  func EqualsCaseless(a, b string) bool {
    12  	aLen := len(a)
    13  	bLen := len(b)
    14  	if aLen != bLen {
    15  		return false
    16  	}
    17  
    18  	for x := 0; x < aLen; x++ {
    19  		charA := uint(a[x])
    20  		charB := uint(b[x])
    21  
    22  		if charA-LowerA <= LowerDiff {
    23  			charA = charA - 0x20
    24  		}
    25  		if charB-LowerA <= LowerDiff {
    26  			charB = charB - 0x20
    27  		}
    28  		if charA != charB {
    29  			return false
    30  		}
    31  	}
    32  
    33  	return true
    34  }