You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This fixes fb_wstr_ConvToA() and also improves fb_wstr_ConvFromA() in the
process.
1. fb_wstr_ConvToA() was definitely broken - it should use wcstombs(), but
that code was commented out, and it only converted ASCII chars, turning
everything else into '?' chars.
Looks like the only reason it was commented out is that the call might
fail. Well, we can use it, and in case it fails, then we can fall back
to the ASCII-only conversion.
2. fb_wstr_ConvFromA() used mbstowcs(), but didn't do ASCII-only conversion
as a fallback. Now it does - seems like it's better to return something
instead of nothing.
3. FB_WSTR_WCHARTOCHAR macro stuff removed, the two functions are now
implemented in the proper module instead of fb_unicode.h, parameters
re-ordered to indicate that dst/dst_chars belong together, while src
must be null-terminated.
4. fb_WstrAssignToAEx() now allocates a big dst string, in the hopes to
have enough room for the decoded multi-byte string (which can be UTF8
on GNU/Linux). Previously it would simply allocate the same amount of
"chars" for dst as were present in src, but the conversion isn't
guaranteed to be 1:1 in terms of chars. Now it will probably often
allocate more memory than needed, but in exchange the string is much
less likely to be truncated.
Unfortunately it is nearly impossible to test this stuff in a portable way.
The Unicode <-> codepage conversions are lossy and depend on the system
codepage at run-time.
Copy file name to clipboardExpand all lines: changelog.txt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Version 1.05.0
14
14
- BYREF fixed-length strings (e.g. BYREF myParameter AS ZSTRING * 10) now trigger a compiler error since they are unsupported
15
15
- #print typeof() output now differentiates between ZSTRING and ZSTRING * N (ZSTRING without size is produced by dereferencing a ZSTRING PTR, or BYREF AS ZSTRING)
16
16
- Context-specific keywords, e.g. graphics PUT modes, must now be given as keywords (e.g. PSET), string literals (e.g. "PSET") are no longer accepted.
17
+
- Wstring-to-Zstring conversions didn't use the system's Unicode <-> codepage conversion function, and only converted ASCII characters. Now it will try to convert the Unicode chars to codepage chars.
0 commit comments