Questions tagged [rune]

In the Go programming language, a rune is a basic data type designed to store a Unicode code point.

58 questions
-1
votes
1 answer

can I remove the trailing zeros in a strings representation ([]byte) to compare strings?

I need to compare strings in Go. The problem is: I want to compare accented words (café) with its non-accented form (cafe). The first thing I do is converting my accented string to its non-accented form with this: you can run the code here:…
nicolasassi
  • 490
  • 4
  • 14
-1
votes
2 answers

GO flag pkg reading option string containing escaped runes like "\u00FC" won't read

The test program below works as desired using the DEFAULT string having code points like \u00FC, as well as if that type of code point is coded as a sting within the prog. Passing the same string from cmd line like: prog.exe -input="ABC\u00FC" does…
-1
votes
1 answer

How to convert a utf8 literal (ie '\u1F606') to a rune? (NOT GET THE UTF8 FROM THE RUNE!)

I'm trying to generate sequential characters using the utf8 hex codes. For example first part, I'm terming "base" code : 259 second part, Im' terming "end" code : 1 (or, 2, or A, or F, etc) These are coming in as strings. Once I append the end code…
bencodesall
  • 69
  • 1
  • 9
-1
votes
1 answer

Golang Increcementing numbers in strings (using runes)

I have a string mixed with characters and numerals, but i want to increment the last character which happens to be a number, here is what i have, it works, but once i reach 10 rune goes to black since 10 decimal is zero, is there a better way to do…
octain
  • 964
  • 3
  • 10
  • 24
-1
votes
2 answers

Why does this conversion in go from a rune-string to integer does not work?

i have the following code: I know about runes in go, i read about them a lot in the last hours i have tried to solve this... package main import ( "fmt" "strconv" ) func main() { e := "\x002" fmt.Println(e) new := string(e) …
jk2
  • 79
  • 7
-2
votes
1 answer

How to convert []string to []rune

I try to write a program that takes as input a phrase and makes up an abbreviation using the first letters of the words. So, "Today I learned" → "TIL" or "Высшее учебное заведение" → "ВУЗ". I dont know how to deal with cyrillic alphabet, so my logic…
Victor
  • 33
  • 7
-2
votes
1 answer

Why am I getting different types in strings?

I have encountered a situation that I do not understand. a := "hello" fmt.Printf("%v %T\n",a[0],a[0]) This gives 104 uint8. for _,v := range a { fmt.Printf("%v %T\n",v,v) } This gives 104 int32 for the first iteration. I…
Shadovx
  • 115
  • 1
  • 8
-2
votes
1 answer

How Convert StringText To Binary And Conversely Using Go

i want Convert Text(type=String) To Binary(type=String) And Conversely Using Go some userfull link : Golang: How to convert String to binary representation & Convert string to binary in Go but i need another. i want example convert a text like…
Love Python
  • 25
  • 2
  • 4
-2
votes
1 answer

How found offset index a string in rune using go

How found offset index a string in []rune using go? I can do this work with string type. if i := strings.Index(input[offset:], "}}"); i > 0 {print(i);} but i need for runes. i have a rune and want get offset index. how can do this work with runes…
Love Python
  • 25
  • 2
  • 4
-2
votes
2 answers

Regex-change substring to uppercase in a string golang

I need to replace a string with a uppercase of the same word.So far i can search for sub-string from a text file which contains my string and replace a word like "apple" or "Apple" or "ApPle" to "APPLE". The problem exist when the string is "Is …
Chetandalal
  • 674
  • 1
  • 7
  • 18
-3
votes
1 answer

Rune is received but struct is not received from chan

I have encountered odd behavior of golang 1.16. For one of my projects I needed to iterate over runes in string. So, I created a simple iterator looks like: func iterRunes(s string) <-chan rune { runes := make(chan rune); go func() { …
Swiatoslaw
  • 11
  • 2
-3
votes
1 answer

Should I ALWAYS use rune instead of string except doing I/O

In Python3, all strings are Unicode so you only need to do decode or encode when doing I/O operation, and in the main part of you code, you only do with Unicode. So, I want to know that in Go, should I do the same? Should I convert all the strings…
Myrfy
  • 575
  • 4
  • 11
-3
votes
1 answer

C++ Unicode: Bytes, Code Points and Graphemes

So, I'm building a scripting language and one of my goals is convenient string operations. I tried some ideas in C++. String as sequences of bytes and free functions that return vectors containing the code-points indices. A wrapper class that…
João Pires
  • 927
  • 1
  • 5
  • 16
1 2 3
4