HuaHuaY commented on issue #50756:
URL: https://github.com/apache/arrow/issues/50756#issuecomment-5142776199

   The second error is not easy to fix. We have these code which use deprecated 
`std::wstring_convert` and `std::codecvt_utf8`. #GH-46576 try to suppress 
compilation errors by adding `ARROW_SUPPRESS_DEPRECATION_WARNING`. But at least 
in my local environment, this error no longer occurs at the template 
definition, but rather where the template is actually instantiated.
   
   ```cpp
   // GH-46576: suppress unicode warnings
   ARROW_SUPPRESS_DEPRECATION_WARNING
   template <typename CHAR_TYPE>
   inline void WcsToUtf8(const void* wcs_string, size_t length_in_code_units,
                         std::vector<uint8_t>* result) {
     thread_local std::wstring_convert<std::codecvt_utf8<CHAR_TYPE>, CHAR_TYPE> 
converter;
     auto byte_string = converter.to_bytes((CHAR_TYPE*)wcs_string,
                                           (CHAR_TYPE*)wcs_string + 
length_in_code_units);
   
     uint32_t length_in_bytes = static_cast<uint32_t>(byte_string.size());
     const uint8_t* data = (uint8_t*)byte_string.data();
   
     result->reserve(length_in_bytes);
     result->assign(data, data + length_in_bytes);
   }
   ARROW_UNSUPPRESS_DEPRECATION_WARNING
   ```
   
   I think there are two ways to fix this:
   1. Wrap the `#include <codecvt>` and `#include <locale>` statements in 
`encoding.h` with `ARROW_SUPPRESS_DEPRECATION_WARNING`. Additionally, any code 
that includes both `encoding.h` and `<locale>` must include `encoding.h` first. 
This is necessary because the deprecation warning must be suppressed the moment 
the compiler encounters `<locale>` within the compilation unit. This is 
inconvenient, as headers like `<vector>` also internally include `<locale>`; 
effectively, if a compilation unit depends—directly or transitively—on 
`encoding.h`, `encoding.h` must be manually included at the very top of the 
source file.
   2. Replace this standard library API with the Boost 
`boost::locale::conv::utf_to_utf`.
   
   @kou @alinaliBQ What do you think about this?
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to