wide.cpp 522 B

123456789101112131415161718
  1. #include "wide.h"
  2. bool CanBeEncoded(TWtringBuf text, ECharset encoding) {
  3. const size_t LEN = 16;
  4. const size_t BUFSIZE = LEN * 4;
  5. char encodeBuf[BUFSIZE];
  6. wchar16 decodeBuf[BUFSIZE];
  7. while (!text.empty()) {
  8. TWtringBuf src = text.NextTokAt(LEN);
  9. TStringBuf encoded = NDetail::NBaseOps::Recode(src, encodeBuf, encoding);
  10. TWtringBuf decoded = NDetail::NBaseOps::Recode(encoded, decodeBuf, encoding);
  11. if (decoded != src)
  12. return false;
  13. }
  14. return true;
  15. }