In the end, I made STRPTR(wstring) return a WSTRING PTR. I couldn't think of any reason it should not. To quote the fb wiki, "Note that when passed a Wstring, Operator Strptr still returns a Zstring Ptr, which may not be the desired result.". My thought is, would it EVER be the desired result. So I think this is a safe change.
Besides, STR(ustring), and WSTR(ustring) can still be used for specific conversions.
I feel like I have made progress over last several weekends. I wrote a lot of tests. The MID assignment statement was a weird one, and I spent some time on that one. Maybe it's bugged, I don't know, it has some peculiar behaviours. For now I left myself a note about it.
I implemented WSTR(ustring) in a way that is close to WSTR(wstring). When testing ustring = WSTR(ustring), I came across an issue in your implementation of the DWSTR in ustring.bi; DECLARE OPERATOR LET (BYREF pwszStr AS WSTRING PTR) clears the buffer. And if pwszStr ptr actually points to itself, the buffer is cleared before the contents are read. Some kind of memory-move would be better.
I think the remaining parts for me are:
- LEFT/RIGHT, which involves fixing a string related bug
- SELECT CASE, which is probably OK
- IIF, which is probably OK, with efficient logic decision
- SWAP, which I need to think about a bit.
- Parameter passing, which is probably OK, so just needs the tests written.
I think I will create a pull request for the work done so far to date. I'll expand on next steps over at fb.net some time this weekend.