Mercurial > repos > rhope
comparison string.rhope @ 52:079200bc3e75
String literals almost working. Print moved out of C runtime.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 28 Apr 2010 01:23:30 -0400 |
parents | 7d6a6906b648 |
children | 048046186d22 |
comparison
equal
deleted
inserted
replaced
51:7d6a6906b648 | 52:079200bc3e75 |
---|---|
15 | 15 |
16 Blueprint Base String | 16 Blueprint Base String |
17 { | 17 { |
18 Buffer | 18 Buffer |
19 Length(Int32,Naked) | 19 Length(Int32,Naked) |
20 } | |
21 | |
22 Print@Base String[string:out] | |
23 { | |
24 //TODO: Sanitize string (remove terminal escapes and replace invalid UTF) | |
25 write[1i32, [string]Buffer >>, Int64[[[string]Buffer >>]Length >>]] | |
26 { out <- write[1i32, [Array[1]]Append[10u8], 1i64] } | |
20 } | 27 } |
21 | 28 |
22 UTF8 Expect[num,arr,index,count,consumed:out] | 29 UTF8 Expect[num,arr,index,count,consumed:out] |
23 { | 30 { |
24 byte <- [arr]Index[index] | 31 byte <- [arr]Index[index] |
111 String[in(Array):out(Base String)] | 118 String[in(Array):out(Base String)] |
112 { | 119 { |
113 out <- [[Build[Base String()]]Buffer <<[in]]Length <<[Count UTF8[in, 0, 0]] | 120 out <- [[Build[Base String()]]Buffer <<[in]]Length <<[Count UTF8[in, 0, 0]] |
114 } | 121 } |
115 | 122 |
116 Main[] | |
117 { | |
118 text <- [[[[[[[[[[[[[Array[1] | |
119 ]Append[36u8] | |
120 ]Append[194u8] | |
121 ]Append[162u8] | |
122 ]Append[236u8] | |
123 ]Append[130u8] | |
124 ]Append[172u8] | |
125 ]Append[240u8] | |
126 ]Append[164u8] | |
127 ]Append[173u8] | |
128 ]Append[162u8] | |
129 ]Append[194u8] | |
130 ]Append[36u8] | |
131 ]Append[162u8] | |
132 Print[Count UTF8[text, 0, 0]] | |
133 } | |
134 | 123 |
124 |