[serialization] Error serializing std::wstring to text_oarchive on VC++
The fill method on mb_from_wchar calls std::wctomb, which is backed by 'WideCharToMultiByte'. This function uses the codepage defined in the current locale, however, the utf-8 codepage does not function properly on VC++ 7 or 8. Would it be difficult to have the conversion use the code_cvt facet defined for the stream underlying the archive? It also seems that doing so would ensure serialization / deserialization would be more consistent and self-sufficient, since neither process would depend on a (mutable) global locale setting. At any rate, the serialization library works with certain window's codepages, but *not* with the utf-8 codepage (65001). It would be nice to have the library use its own utf8_code_cvt facet to translate wide characters to multibyte. If there is some work around I'm not aware of, I would appreciate any advice. Thanks.
William Kemper wrote:
The fill method on mb_from_wchar calls std::wctomb, which is backed by 'WideCharToMultiByte'. This function uses the codepage defined in the current locale, however, the utf-8 codepage does not function properly on VC++ 7 or 8. Would it be difficult to have the conversion use the code_cvt facet defined for the stream underlying the archive?
I'm not sure how that would work. the streambuffer for text_?archive takes multi-byte char as input while the one you need takes a wchar.
It also seems that doing so would ensure serialization / deserialization would be more consistent and self-sufficient, since neither process would depend on a (mutable) global locale setting. At any rate, the serialization library works with certain window's codepages, but *not* with the utf-8 codepage (65001). It would be nice to have the library use its own utf8_code_cvt facet to translate wide characters to multibyte. If there is some work around I'm not aware of, I would appreciate any advice. Thanks.
This is a pretty tough one. I would think the base thing is to fix the problem at its source. I'm not sure which locale uses utf-8 but in any case maybe you want to create a "correct locale" based on the erroneious one. Then make the "correct locale" the current one. THat would fix the problem for serialization along with any other code that might be depending on broken functionality. Robert Ramey
participants (2)
-
Robert Ramey
-
William Kemper