gonum.org/v1/gonum@v0.14.0/graph/formats/dot/internal/util/rune.go (about)

     1  // Code generated by gocc; DO NOT EDIT.
     2  
     3  // This file is dual licensed under CC0 and The Gonum License.
     4  //
     5  // Copyright ©2017 The Gonum Authors. All rights reserved.
     6  // Use of this source code is governed by a BSD-style
     7  // license that can be found in the LICENSE file.
     8  //
     9  // Copyright ©2017 Robin Eklind.
    10  // This file is made available under a Creative Commons CC0 1.0
    11  // Universal Public Domain Dedication.
    12  
    13  package util
    14  
    15  import (
    16  	"fmt"
    17  )
    18  
    19  func RuneToString(r rune) string {
    20  	if r >= 0x20 && r < 0x7f {
    21  		return fmt.Sprintf("'%c'", r)
    22  	}
    23  	switch r {
    24  	case 0x07:
    25  		return "'\\a'"
    26  	case 0x08:
    27  		return "'\\b'"
    28  	case 0x0C:
    29  		return "'\\f'"
    30  	case 0x0A:
    31  		return "'\\n'"
    32  	case 0x0D:
    33  		return "'\\r'"
    34  	case 0x09:
    35  		return "'\\t'"
    36  	case 0x0b:
    37  		return "'\\v'"
    38  	case 0x5c:
    39  		return "'\\\\\\'"
    40  	case 0x27:
    41  		return "'\\''"
    42  	case 0x22:
    43  		return "'\\\"'"
    44  	}
    45  	if r < 0x10000 {
    46  		return fmt.Sprintf("\\u%04x", r)
    47  	}
    48  	return fmt.Sprintf("\\U%08x", r)
    49  }