github.com/dolthub/go-mysql-server@v0.18.0/sql/encodings/latin1_bin.go (about)

     1  // Copyright 2022 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package encodings
    16  
    17  // Latin1_bin_RuneWeight returns the weight of a given rune based on its relational sort order from
    18  // the `latin1_bin` collation.
    19  func Latin1_bin_RuneWeight(r rune) int32 {
    20  	weight, ok := latin1_bin_Weights[r]
    21  	if ok {
    22  		return weight
    23  	} else if r >= 0 && r <= 127 {
    24  		return r + 0
    25  	} else {
    26  		return 2147483647
    27  	}
    28  }
    29  
    30  // latin1_bin_Weights contain a map from rune to weight for the `latin1_bin` collation. The
    31  // map primarily contains mappings that have a random order. Mappings that fit into a sequential range (and are long
    32  // enough) are defined in the calling function to save space.
    33  var latin1_bin_Weights = map[rune]int32{
    34  	8364: 128,
    35  	129:  129,
    36  	8218: 130,
    37  	402:  131,
    38  	8222: 132,
    39  	8230: 133,
    40  	8224: 134,
    41  	8225: 135,
    42  	710:  136,
    43  	8240: 137,
    44  	352:  138,
    45  	8249: 139,
    46  	338:  140,
    47  	141:  141,
    48  	381:  142,
    49  	143:  143,
    50  	144:  144,
    51  	8216: 145,
    52  	8217: 146,
    53  	8220: 147,
    54  	8221: 148,
    55  	8226: 149,
    56  	8211: 150,
    57  	8212: 151,
    58  	732:  152,
    59  	8482: 153,
    60  	353:  154,
    61  	8250: 155,
    62  	339:  156,
    63  	157:  157,
    64  	382:  158,
    65  	376:  159,
    66  	160:  160,
    67  	161:  161,
    68  	162:  162,
    69  	163:  163,
    70  	164:  164,
    71  	165:  165,
    72  	166:  166,
    73  	167:  167,
    74  	168:  168,
    75  	169:  169,
    76  	170:  170,
    77  	171:  171,
    78  	172:  172,
    79  	173:  173,
    80  	174:  174,
    81  	175:  175,
    82  	176:  176,
    83  	177:  177,
    84  	178:  178,
    85  	179:  179,
    86  	180:  180,
    87  	181:  181,
    88  	182:  182,
    89  	183:  183,
    90  	184:  184,
    91  	185:  185,
    92  	186:  186,
    93  	187:  187,
    94  	188:  188,
    95  	189:  189,
    96  	190:  190,
    97  	191:  191,
    98  	192:  192,
    99  	193:  193,
   100  	194:  194,
   101  	195:  195,
   102  	196:  196,
   103  	197:  197,
   104  	198:  198,
   105  	199:  199,
   106  	200:  200,
   107  	201:  201,
   108  	202:  202,
   109  	203:  203,
   110  	204:  204,
   111  	205:  205,
   112  	206:  206,
   113  	207:  207,
   114  	208:  208,
   115  	209:  209,
   116  	210:  210,
   117  	211:  211,
   118  	212:  212,
   119  	213:  213,
   120  	214:  214,
   121  	215:  215,
   122  	216:  216,
   123  	217:  217,
   124  	218:  218,
   125  	219:  219,
   126  	220:  220,
   127  	221:  221,
   128  	222:  222,
   129  	223:  223,
   130  	224:  224,
   131  	225:  225,
   132  	226:  226,
   133  	227:  227,
   134  	228:  228,
   135  	229:  229,
   136  	230:  230,
   137  	231:  231,
   138  	232:  232,
   139  	233:  233,
   140  	234:  234,
   141  	235:  235,
   142  	236:  236,
   143  	237:  237,
   144  	238:  238,
   145  	239:  239,
   146  	240:  240,
   147  	241:  241,
   148  	242:  242,
   149  	243:  243,
   150  	244:  244,
   151  	245:  245,
   152  	246:  246,
   153  	247:  247,
   154  	248:  248,
   155  	249:  249,
   156  	250:  250,
   157  	251:  251,
   158  	252:  252,
   159  	253:  253,
   160  	254:  254,
   161  	255:  255,
   162  }