github.com/searKing/golang/go@v1.2.117/log/slog/json_handler.go (about)

     1  // Copyright 2023 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package slog
     6  
     7  import "unicode/utf8"
     8  
     9  // Copied from encoding/json/tables.go.
    10  //
    11  // safeSet holds the value true if the ASCII character with the given array
    12  // position can be represented inside a JSON string without any further
    13  // escaping.
    14  //
    15  // All values are true except for the ASCII control characters (0-31), the
    16  // double quote ("), and the backslash character ("\").
    17  var safeSet = [utf8.RuneSelf]bool{
    18  	' ':      true,
    19  	'!':      true,
    20  	'"':      false,
    21  	'#':      true,
    22  	'$':      true,
    23  	'%':      true,
    24  	'&':      true,
    25  	'\'':     true,
    26  	'(':      true,
    27  	')':      true,
    28  	'*':      true,
    29  	'+':      true,
    30  	',':      true,
    31  	'-':      true,
    32  	'.':      true,
    33  	'/':      true,
    34  	'0':      true,
    35  	'1':      true,
    36  	'2':      true,
    37  	'3':      true,
    38  	'4':      true,
    39  	'5':      true,
    40  	'6':      true,
    41  	'7':      true,
    42  	'8':      true,
    43  	'9':      true,
    44  	':':      true,
    45  	';':      true,
    46  	'<':      true,
    47  	'=':      true,
    48  	'>':      true,
    49  	'?':      true,
    50  	'@':      true,
    51  	'A':      true,
    52  	'B':      true,
    53  	'C':      true,
    54  	'D':      true,
    55  	'E':      true,
    56  	'F':      true,
    57  	'G':      true,
    58  	'H':      true,
    59  	'I':      true,
    60  	'J':      true,
    61  	'K':      true,
    62  	'L':      true,
    63  	'M':      true,
    64  	'N':      true,
    65  	'O':      true,
    66  	'P':      true,
    67  	'Q':      true,
    68  	'R':      true,
    69  	'S':      true,
    70  	'T':      true,
    71  	'U':      true,
    72  	'V':      true,
    73  	'W':      true,
    74  	'X':      true,
    75  	'Y':      true,
    76  	'Z':      true,
    77  	'[':      true,
    78  	'\\':     false,
    79  	']':      true,
    80  	'^':      true,
    81  	'_':      true,
    82  	'`':      true,
    83  	'a':      true,
    84  	'b':      true,
    85  	'c':      true,
    86  	'd':      true,
    87  	'e':      true,
    88  	'f':      true,
    89  	'g':      true,
    90  	'h':      true,
    91  	'i':      true,
    92  	'j':      true,
    93  	'k':      true,
    94  	'l':      true,
    95  	'm':      true,
    96  	'n':      true,
    97  	'o':      true,
    98  	'p':      true,
    99  	'q':      true,
   100  	'r':      true,
   101  	's':      true,
   102  	't':      true,
   103  	'u':      true,
   104  	'v':      true,
   105  	'w':      true,
   106  	'x':      true,
   107  	'y':      true,
   108  	'z':      true,
   109  	'{':      true,
   110  	'|':      true,
   111  	'}':      true,
   112  	'~':      true,
   113  	'\u007f': true,
   114  }