Skip to content

Commit 28bd1b5

Browse files
committed
rtlib: string and wstring conversions
In previous commit (Skyfish) converting between string and wstring uses multi-byte & wide character functions wctombs() & mbtowcs() However, on DOS wctombs() & mbtowcs() just map to memcpy, so keep the previous string length calculation for DOS only. (cherry picked from commit bade534)
1 parent 22f062a commit 28bd1b5

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Version 1.07.2
1717
- github #258: on windows directx and gdi drivers, only show window after intialization is complete (adeyblue)
1818
- sf.net #925: CSIGN/CUNSG preserve size when converting pointers on 64-bit and implict conversion of STEP value in FOR...NEXT statement
1919
- github #122: gfxlib2: linux GFX_NO_FRAME + GFX_OPENGL freezing at exit due to a dead lock between exit routines
20+
- use the multi-byte & wide character functions wctombs() & mbtowcs() when converting between string and wstring (Skyfish)
2021

2122

2223
Version 1.07.1

src/rtlib/strw_convfrom_str.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ FBCALL FB_WCHAR *fb_StrToWstr( const char *src )
6161
if( src == NULL )
6262
return NULL;
6363

64+
#if defined HOST_DOS
65+
/* on DOS, mbstowcs() simply calls memcpy() and won't compute
66+
length see fb_unicode.h */
67+
chars = strlen( src );
68+
#else
6469
chars = mbstowcs( NULL, src, 0 );
70+
#endif
6571
if( chars == 0 )
6672
return NULL;
6773

src/rtlib/strw_convto_str.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ FBCALL FBSTRING *fb_WstrToStr( const FB_WCHAR *src )
7272
if( src == NULL )
7373
return &__fb_ctx.null_desc;
7474

75+
#if defined HOST_DOS
76+
/* on DOS, wcstombs() simply calls memcpy() and won't compute
77+
length see fb_unicode.h */
78+
chars = fb_wstr_Len( src );
79+
#else
7580
chars = wcstombs( NULL, src, 0 );
81+
#endif
7682
if( chars == 0 )
7783
return &__fb_ctx.null_desc;
7884

0 commit comments

Comments
 (0)