I
I
IronFil2015-07-06 23:07:45
go
IronFil, 2015-07-06 23:07:45

How to select a substring of a utf8 string on GO?

slash := "I'm a UTF8 STRING GET A SUBSTRING FROM ME" I
want to get a substring, the standard cut works by bytes, so nothing worthwhile happens.
Another question is whether it is possible to immediately create a string, each character of which is 4 bytes, so that you can safely get the desired character by index, or is there another way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
valm0unt, 2015-07-07
@IronFil

str := `I am a UTF8 STRING GET A SUBSTRING FROM ME`
fmt.Println(string([]rune(str)[5:9]))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question