I would like that strings can be assigned directly to seq[uint8], as a cstring 
generally is a valid uint8 sequence.

Something like
    
    
    var s: seq[uint8]
    s = seq[uint8]("Text data for proc with uint8 based parameters".cstring)
    
    
    Run

The actual fact is, that we have some gtk procs that gets a utf8 array, that is 
a pointer to first utf8 char and an length argument. In earlier gintro releases 
I used a faked cstring for this, which is ok in most cases, but maybe not in 
all, as uint8 array can contain binary zero multiple times.

The basic API design was that the high level proc got a string and passed 
cstring and length to C lib. Now the correct high level API get a seq[uint8] 
and passes addr of first entry and length to C lib. That should be fine, but it 
is unconvenient for the user, as he can not simple pass a string.

I think one solution may be, that I make the parameter of the high level API an 
or type, this is "s: seq[uint8] or string". Then the low level code remains 
identical, as both arguments have addr(s[0]) and s.len.

But general, a pure assign of string to seq[uint8] may be useful generally, 
maybe a plain cast may even work, but I newer would use that. 

Reply via email to