The below golang code will print the input rune by rune.
package main
import (
"bufio"
"fmt"
"strings"
)
// This method is no-good for emojis.
// Also note the differences between the first and the second ペンギン.
// We should consider using: https://github.com/rivo/uniseg
func Example() {
input := `abcdefg1234567890あいうえお💩👍🏼!ペンギンペンギンペンギン`
inputReader := strings.NewReader(input)
scanner := bufio.NewScanner(inputReader)
scanner.Split(bufio.ScanRunes)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
// Output:
// a
// b
// c
// d
// e
// f
// g
// 1
// 2
// 3
// 4
// 5
// 6
// 7
// 8
// 9
// 0
// あ
// い
// う
// え
// お
// 💩
// 👍
// 🏼
// !
// ヘ
// ゚
// ン
// キ
// ゙
// ン
// ヘ
// ゚
// ン
// キ
// ゙
// ン
// ペ
// ン
// ギ
// ン
}
- View it online @ GoPlayground