当前位置: 首页>>代码示例>>Golang>>正文


Golang strconv.QuoteRuneToASCII函数代码示例

本文整理汇总了Golang中strconv.QuoteRuneToASCII函数的典型用法代码示例。如果您正苦于以下问题:Golang QuoteRuneToASCII函数的具体用法?Golang QuoteRuneToASCII怎么用?Golang QuoteRuneToASCII使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QuoteRuneToASCII函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: lexChar

func lexChar(l *Lexer) stateFn {
Loop:
	for {
		switch l.next() {
		case '"':
			fmt.Println(string(l.input[l.pos-2]))
			if l.input[l.pos-2] != '\\' {
				return l.errorf("unescaped char %s", string(l.input[l.pos-1]))
			}
		case '\\':
			if ok := runeIsEscape(l.peek()); !ok {
				return l.errorf("Not an escape character %s", strconv.QuoteRuneToASCII(l.next()))
			} else {
				l.next()
				break
			}
			fallthrough
		case eof, '\n':
			return l.errorf("unterminated character constant")
		case '\'':
			break Loop
		}
	}
	l.emit(CHARACTER)
	return lexInsideProgram
}
开发者ID:henrykhadass,项目名称:Year2Compiler,代码行数:26,代码来源:lex.go

示例2: ExampleQuoteRuneToASCII

func ExampleQuoteRuneToASCII() {
	s := strconv.QuoteRuneToASCII('☺')
	fmt.Println(s)

	// Output:
	// '\u263a'
}
开发者ID:RajibTheKing,项目名称:gcc,代码行数:7,代码来源:example_test.go

示例3: createFromMixed

// Create normalized array of rows from mixed data (interface{})
func createFromMixed(data [][]interface{}, format byte) []*TabulateRow {
	rows := make([]*TabulateRow, len(data))
	for index_1, element := range data {
		normalized := make([]string, len(element))
		for index, el := range element {
			switch el.(type) {
			case int32:
				quoted := strconv.QuoteRuneToASCII(el.(int32))
				normalized[index] = quoted[1 : len(quoted)-1]
			case int:
				normalized[index] = strconv.Itoa(el.(int))
			case int64:
				normalized[index] = strconv.FormatInt(el.(int64), 10)
			case bool:
				normalized[index] = strconv.FormatBool(el.(bool))
			case float64:
				normalized[index] = strconv.FormatFloat(el.(float64), format, -1, 64)
			case uint64:
				normalized[index] = strconv.FormatUint(el.(uint64), 10)
			case nil:
				normalized[index] = "nil"
			default:
				normalized[index] = fmt.Sprintf("%s", el)
			}
		}
		rows[index_1] = &TabulateRow{Elements: normalized}
	}
	return rows
}
开发者ID:wwek,项目名称:ncgo,代码行数:30,代码来源:utils.go

示例4: main

func main() {
	file, err := os.Open(os.Args[1])
	if err != nil {
		log.Fatal(err)
	}
	defer file.Close()

	scanner := bufio.NewScanner(file)
	scanner.Scan() //scan line number line
	ln, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	var s string
	for i := 1; i <= ln; i++ {
		scanner.Scan()
		tmp := scanner.Text()
		tmp = strings.ToLower(tmp)
		for _, r := range tmp {
			//rc := strconv.QuoteRuneToASCII(r)
			if r >= 'a' && r <= 'z' {
				s += strconv.QuoteRuneToASCII(r)
			}
		}
	}

	if s == reverse(s) {
		fmt.Println("Palindrome")
	} else {
		fmt.Println("Not a Palindrome")
	}
}
开发者ID:Maphardam,项目名称:DailyProgrammer,代码行数:33,代码来源:solution.go

示例5: fmt_qc

// fmt_qc formats the integer as a single-quoted, escaped Go character constant.
// If the character is not valid Unicode, it will print '\ufffd'.
func (f *fmt) fmt_qc(c int64) {
	var quoted string
	if f.plus {
		quoted = strconv.QuoteRuneToASCII(int(c))
	} else {
		quoted = strconv.QuoteRune(int(c))
	}
	f.padString(quoted)
}
开发者ID:WXB506,项目名称:golang,代码行数:11,代码来源:format.go

示例6: printAsciiByte

// Print a byte as ASCII, using escape sequences where necessary.
func printAsciiByte(b uint8) {
	r := rune(b)
	if unicode.IsPrint(r) || unicode.IsSpace(r) {
		fmt.Print(string(r))
	} else {
		charStr := strconv.QuoteRuneToASCII(r)
		fmt.Print(charStr[1 : len(charStr)-1])
	}
}
开发者ID:pda,项目名称:go6502,代码行数:10,代码来源:via6522.go

示例7: StringShow0i

func (z *ConstNumber) StringShow0i(show0i bool) string {
	if z.Type == ConstRune && z.Value.Re.Num().BitLen() <= 32 {
		r, _, _ := z.Value.Int(32)
		return strconv.QuoteRuneToASCII(rune(r))
	} else if z.Type == ConstComplex {
		return z.Value.StringShow0i(show0i)
	} else {
		return z.Value.StringShow0i(false)
	}
}
开发者ID:raff,项目名称:eval,代码行数:10,代码来源:constnumber.go

示例8: createFromInt32

// Create normalized array from ints32
func createFromInt32(data [][]int32) []*TabulateRow {
	rows := make([]*TabulateRow, len(data))
	for index_1, arr := range data {
		row := make([]string, len(arr))
		for index, el := range arr {
			quoted := strconv.QuoteRuneToASCII(el)
			row[index] = quoted[1 : len(quoted)-1]
		}
		rows[index_1] = &TabulateRow{Elements: row}
	}
	return rows
}
开发者ID:wwek,项目名称:ncgo,代码行数:13,代码来源:utils.go

示例9: getOperatorsAndOperands

func (filter *ScenarioFilterBasedOnTags) getOperatorsAndOperands() ([]string, []string) {
	listOfOperators := make([]string, 0)
	listOfTags := strings.FieldsFunc(filter.tagExpression, func(r rune) bool {
		isValidOperator := r == '&' || r == '|' || r == '(' || r == ')' || r == '!'
		if isValidOperator {
			operator, _ := strconv.Unquote(strconv.QuoteRuneToASCII(r))
			listOfOperators = append(listOfOperators, operator)
			return isValidOperator
		}
		return false
	})
	return listOfOperators, listOfTags
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:13,代码来源:specItemFilter.go

示例10: Decode

func Decode(code string) (lat, lon float64) {
	var _decode = func(character []rune) float64 {
		var loc float64
		first := strconv.QuoteRuneToASCII(character[0])
		second := strconv.QuoteRuneToASCII(character[1])
		val, _ := strconv.ParseInt("0x"+first[3:7]+second[3:7], 0, 32)
		sval := strconv.FormatInt(val, 10)
		loc = 1
		if val < 2000000000 {
			loc = -1
		}
		if val > 1000000000 {
			val, _ = strconv.ParseInt(sval[2:], 0, 0)
		}
		fval := math.Mod(float64(val), 1000000000)
		if sval[1] == 1 || sval[1] == 3 {
			fval += 90
		}
		return fval / 10000000 * loc
	}
	return _decode([]rune(code)[:2]), _decode([]rune(code)[2:])
}
开发者ID:wmak,项目名称:Talon,代码行数:22,代码来源:talon.go

示例11: NextKey

func (w *Worker) NextKey(f rune) uint64 {
	if !w.PreAllocated {
		w.next++
		x := uint64(w.next<<16) | uint64(w.ID)<<8 | uint64(w.next%CHUNKS)
		return x
	}
	if w.LastKey[f] == w.CurrKey[f] {
		log.Fatalf("%v Ran out of preallocated keys for %v; %v %v", w.ID, strconv.QuoteRuneToASCII(f), w.CurrKey[f], w.LastKey[f])
	}
	y := uint64(w.CurrKey[f] + w.start)
	x := uint64(y<<16) | uint64(w.ID)<<8 | y%CHUNKS
	w.CurrKey[f]++
	return x
}
开发者ID:ngaut,项目名称:ddtxn,代码行数:14,代码来源:worker.go

示例12: getCenter

func getCenter(w string) string {
	result := ""
	for idx, letter := range w {
		sideA, sideB := w[:idx], w[(idx+1):]
		sumA, sumB := sumSides(sideA, sideB)
		if sumA-sumB == 0 {
			result = fmt.Sprint(sideA, " ", strconv.QuoteRuneToASCII(letter), " ", sideB, " - ", sumA)
			break
		}
	}
	if result == "" {
		result = fmt.Sprint(w, " DOES NOT BALANCE")
	}

	return result
}
开发者ID:muhang,项目名称:daily-programmer,代码行数:16,代码来源:7-06.go

示例13: HexBuffer1

// http://play.golang.org/p/pKPEeNWsjD
// 用来escape 特殊字符  "Hello, '世界'" => E'Hello, \'\u4e16\u754c\''
func HexBuffer1(input string) string {
	output := make([]byte, 0, 3+len(input))
	output = append(output, "E'"...)
	for _, r := range input {
		var s string
		switch r {
		case '\'':
			s = `\'`
		case '\\':
			s = `\\`
		default:
			s = strconv.QuoteRuneToASCII(r)
			// get rid of surrounding single quote
			s = s[1 : len(s)-1]
		}
		output = append(output, s...)
	}
	return string(append(output, '\''))
}
开发者ID:notedit,项目名称:eightfoot,代码行数:21,代码来源:utils.go

示例14: Solution

func Solution(expression string) int {
	// write your code in Go 1.4
	stack := Stack{}
	fmt.Println(expression)
	for _, element := range expression {
		value, err := strconv.Atoi(string(element))

		if err != nil {
			operand1, err := stack.Pop()
			if err != nil {
				return -1
			}
			operand2, err := stack.Pop()
			if err != nil {
				return -1
			}

			operation := strconv.QuoteRuneToASCII(element)
			if operation == "'+'" {
				total := operand1 + operand2
				stack.Push(total)
			} else if operation == "'*'" {
				total := operand1 * operand2
				stack.Push(total)
			} else {
				return -1
			}
		} else {
			stack.Push(value)
		}
	}

	finalValue, err := stack.Pop()
	if err != nil {
		return -1
	} else {
		return finalValue
	}
}
开发者ID:luck02,项目名称:StackCalcTests,代码行数:39,代码来源:split.go

示例15: rtoa

func rtoa(r rune) string {
	return strconv.QuoteRuneToASCII(r)
}
开发者ID:nstratos,项目名称:mdt,代码行数:3,代码来源:helpers.go


注:本文中的strconv.QuoteRuneToASCII函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。