From 248388f5de6bd9e7278bc269eb1f415594c7ac3d Mon Sep 17 00:00:00 2001 From: sebastian Date: Wed, 29 Nov 2023 12:42:04 +0100 Subject: [PATCH] Section12 - 94 --- Section12/90.go | 32 ++++++++++++++++++++++++++++++++ Section12/93.go | 29 +++++++++++++++++++++++++++++ Section12/94.go | 18 ++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 Section12/90.go create mode 100644 Section12/93.go create mode 100644 Section12/94.go diff --git a/Section12/90.go b/Section12/90.go new file mode 100644 index 0000000..7da062b --- /dev/null +++ b/Section12/90.go @@ -0,0 +1,32 @@ +package main + +import "fmt" + +func main() { + s1 := "Hi there Go!" + fmt.Println(s1) + + fmt.Println("He sais: \"Hello!\"") + fmt.Println(`He sais: "Hello again!"`) + + s2 := `I like \n Go!` //raw string + fmt.Println(s2) + + fmt.Println("Price: 100\nBrand: Nike") + fmt.Println(` +Price: 100 +Brand: Nike + `) + fmt.Println(`C:\Users\Sebastian`) + fmt.Println("C:\\Users\\Sebastian") + + var s3 = "I love " + "Go " + "Programming" + fmt.Println(s3 + "!") + + fmt.Println("Element at index 0:", s3[0]) + + // s3[5] = 'x' + fmt.Printf("%s\n", s3) + fmt.Printf("%q\n", s3) + +} diff --git a/Section12/93.go b/Section12/93.go new file mode 100644 index 0000000..5e0eb5f --- /dev/null +++ b/Section12/93.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "strings" + "unicode/utf8" +) + +func main() { + var1, var2 := 'a', 'b' + + fmt.Printf("Type: %T, Value: %d\n", var1, var2) + + str := "țară" + fmt.Println(len(str)) + + fmt.Println("Byte (non rune) at position 1:", str[1]) + + for i := 0; i < len(str); i++ { + fmt.Printf("%c", str[i]) + } + fmt.Println("\n" + strings.Repeat("#", 20)) + for i := 0; i < len(str); { + r, size := utf8.DecodeRuneInString(str[i:]) + fmt.Printf("%c", r) + i += size + } + fmt.Println("\n" + strings.Repeat("#", 20)) +} diff --git a/Section12/94.go b/Section12/94.go new file mode 100644 index 0000000..03f7cde --- /dev/null +++ b/Section12/94.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "unicode/utf8" +) + +func main() { + s1 := "Golang" + fmt.Println(len(s1)) + + name := "Codruța" + fmt.Println(len(name)) + + n := utf8.RuneCountInString(name) + fmt.Println(n) + +}