start working on the utf8 strings vocabulary
FossilOrigin-Name: 498355a2edc0bc1a5d091583298bab8821a2df0bc217e90f9ab78925ce5dc0c4
This commit is contained in:
parent
5fcf120526
commit
38cd29b8b2
1 changed files with 38 additions and 0 deletions
38
future/utf8.retro
Normal file
38
future/utf8.retro
Normal file
|
@ -0,0 +1,38 @@
|
|||
# UTF-8 Strings
|
||||
|
||||
Strings in Retro have been C-style null terminated sequences of ASCII
|
||||
characters. I'm seeking to change this as I'd like to support Unicode
|
||||
(UTF-8) and to merge much of the string and array handling code.
|
||||
|
||||
This will be an ongoing process.
|
||||
|
||||
Temporary sigil.
|
||||
|
||||
~~~
|
||||
:sigil:" (-a) a:from-string class:data ; immediate
|
||||
~~~
|
||||
|
||||
Return the length (in utf8 characters or bytes) of a string.
|
||||
|
||||
~~~
|
||||
:us:length (a-n) #0 swap [ #192 and #128 -eq? + ] a:for-each n:abs ;
|
||||
:us:length/bytes (a-n) a:length ;
|
||||
~~~
|
||||
|
||||
Fetch a character from a string.
|
||||
|
||||
~~~
|
||||
~~~
|
||||
|
||||
Store a character into a string.
|
||||
|
||||
~~~
|
||||
~~~
|
||||
|
||||
Tests.
|
||||
|
||||
```
|
||||
"((V⍳V)=⍳⍴V)/V←,V us:length n:put nl
|
||||
"((V⍳V)=⍳⍴V)/V←,V us:length/bytes n:put nl
|
||||
```
|
||||
|
Loading…
Reference in a new issue