Closed mhavu closed 4 years ago
Not sure in like thew change to
public var utf8CString: [UTF8Char] {
as thats a lot of overhead when the most common case for this property is to get a raw native byte array to work with the string data (possibly to pass to C APIs or the like)...
as thats a lot of overhead when the most common case for this property is to get a raw native byte array to work with the string data (possibly to pass to C APIs or the like)...
Yes, I'm using it to get a char*
for C APIs, and currently there is no implementation on Island. Isn't it so that the native strings in all the other platforms except Cocoa use wide characters? Should I just add a String extension in my own code then?
Yeah, but [UTF8Chat] is a bad way to get a char*, because [T] is a complex type implementing the Swift array type semantics. by comparison, T[] is a "native" array — ie just bytes in memory.
You really wanna keep tis property as UTF8Char[]
, because then you literally can grab its address and have a char*
. if it's [UTF8Char]
you then still have to get the real array our of it, which is an extra copy operation, (and just t give you a UTF8Char[]
that you could have gotten from the getgo.
if that makes sense?
Yeah, but [UTF8Chat] is a bad way to get a char*, because [T] is a complex type implementing the Swift array type semantics. by comparison, T[] is a "native" array — ie just bytes in memory.
I wasn't aware of such semantic difference. I'll fix it.
this one also failed, for Java :(
Sorry about that. I get E: Internal error: System.Exception: Invalid tag for constant pool item
on Cooper, too.
I changed
String.init(count:repeatedValue:)
withinit(repeating:count:)
(a change introduced in Swift 3) and addedString.utf8CString
for CLR and ISLAND (unfortunately no JAVA – which Java version should one target?).