wchar_t * wSrc = L"\xa9" L"12345" ;
char dest[10] ;
wchar_t wdest[10] ;
wcstombs(dest, wSrc, 10 ) ;
mbstowcs(wdest, dest, 10 ) ;
// r should be 0 but isn't
int r = wcscmp(wSrc, wdest) ;
This is using the C++ carbon toolbox stationary with CW8.3 on
OSX10.2.4
How can i round trip between mbcs and wchar_t ?
Thanks
Simon
Engineering thinks if found a bug,
change mbstring.c line 217, which should be
*pwc = *s & 0x00ff; /*- mm 030401 -*/
However I tested it and it didn't work for me. If you want to give it a
shot let me know. (don't forget to rebuild the library). If it doesn't
work let us know more about what you are using, Carbon, or Mach-O etc.
Ron
--
Migrate your PowerPlant Applications to Windows
http://www.metrowerks.com/MW/Services/OEM/default.htm
Ron Liechty - MW...@metrowerks.com - http://www.metrowerks.com
I doubt that would work, i ended up doing this
*pwc = *((unsigned char *)s) ;
I also found that the r versions ( wcsrtombs & mbsrtowcs ) have issues
that prevent round tripping, in that wcsrtombs generates a UTF-8
stream, but mbstrtowcs will not correctly handle an input stream
containing UTF-8.
Cheers
Simon
>MW Ron <mw...@metrowerks.com> wrote in message
>news:<mwron-0DE8DD....@enews.newsguy.com>...
>>>[snip]
>> Engineering thinks if found a bug,
>> change mbstring.c line 217, which should be
>>
>> *pwc = *s & 0x00ff; /*- mm 030401 -*/
>>
>> However I tested it and it didn't work for me. If you want to give it a
>> shot let me know. (don't forget to rebuild the library). If it doesn't
>> work let us know more about what you are using, Carbon, or Mach-O etc.
>>
>> Ron
>
>I doubt that would work, i ended up doing this
>*pwc = *((unsigned char *)s) ;
It worked for me but there may be some other changes I didn't notice.
When I looked at this again today I found that the mbstring.c had
changed quite a bit more than I thought in the next release.
>I also found that the r versions ( wcsrtombs & mbsrtowcs ) have issues
>that prevent round tripping, in that wcsrtombs generates a UTF-8
>stream, but mbstrtowcs will not correctly handle an input stream
>containing UTF-8.
I'll pass this on to our engineer
Thanks,