Equal reports whether addr1 and addr2 are considered to be case-insensitively equivalent. The equivalence is defined to be the conjunction of IDN label equivalence for the domain part and canonical equivalence* of the local-part converted to lower case. * IDN label equivalence is defined by RFC 58
(addr1, addr2 string)
| 103 | // Equivalence for malformed addresses is defined using regular byte-string |
| 104 | // comparison with case-folding applied. |
| 105 | func Equal(addr1, addr2 string) bool { |
| 106 | // Short circuit. If they are bit-equivalent, then they are also canonically |
| 107 | // equivalent. |
| 108 | if addr1 == addr2 { |
| 109 | return true |
| 110 | } |
| 111 | |
| 112 | uAddr1, _ := ForLookup(addr1) |
| 113 | uAddr2, _ := ForLookup(addr2) |
| 114 | return uAddr1 == uAddr2 |
| 115 | } |
| 116 | |
| 117 | func IsASCII(s string) bool { |
| 118 | for _, ch := range s { |