From 598dab5bc4fb2836c8f2a6cad757dcb3760a895f Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Mon, 28 Nov 2016 20:39:43 +0000 Subject: #rune "" to ''; Remove infix and postfix call notation --- code/demo.odin | 31 ++++++++++++++++++++++++++++++- code/game.odin | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'code') diff --git a/code/demo.odin b/code/demo.odin index a1916e589..e516d3529 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -1,5 +1,34 @@ #import "fmt.odin" +#import "utf8.odin" main :: proc() { - fmt.println("Hellope, World!") + MAX :: 64 + buf: [MAX]rune + backing: [MAX]byte + offset: int + + msg := "Hello" + count := utf8.rune_count(msg) + assert(count <= MAX) + runes := buf[:count] + + offset = 0 + for i := 0; i < count; i++ { + s := msg[offset:] + r, len := utf8.decode_rune(s) + runes[count-i-1] = r + offset += len + } + + offset = 0 + for i := 0; i < count; i++ { + data, len := utf8.encode_rune(runes[i]) + for j := 0; j < len; j++ { + backing[offset+j] = data[j] + } + offset += len + } + + reverse := backing[:count] as string + fmt.println(reverse) } diff --git a/code/game.odin b/code/game.odin index c5d0c52f2..4760f0244 100644 --- a/code/game.odin +++ b/code/game.odin @@ -4,7 +4,7 @@ #import "os.odin" #import "opengl.odin" as gl -TWO_HEARTS :: #rune "💕" +TWO_HEARTS :: '💕' win32_perf_count_freq := win32.GetQueryPerformanceFrequency() time_now :: proc() -> f64 { -- cgit v1.2.3