Subsubtopic: dereferencing and strings (especially interop)


#1

Continuing the discussion from (Wrong) Direction of rust:


Branch to Rust compared to C# on all except string comparison



Rust beginner notes & questions
#2

The relevant quotes from the first post are shown below. This topic derives from (Wrong) Direction of Rust


#3

There is a good reason for that. For example, Rust uses UTF-8 for its own strings, null chars are allowed, and string are not null-terminated. One can’t happily call C functions using them, because C expects a different kind of strings. Windows also doesn’t work with UTF-8 natively, it expects UTF-16. So all this string types simply state that they are internally incompatible among each other.

In C# there is the same problem, just upside down. It uses UTF-16 internally as does Windows, but at the same time it lacks UTF-8 strings, one only can have them as byte arrays. One practically can’t have an “one-size-fits-all” string type.