src/net/ntlm/ntlm_client_unittest.cc
// Reads bytes from a payload and assigns them to a string16. This makes
// no assumptions about the underlying encoding. This will fail if there
// are an odd number of bytes in the payload.
Reads bytes from a payload and assigns them to a string16. This makes
no assumptions about the underlying encoding. This will fail if there
are an odd number of bytes in the payload.
Reads bytes from a payload and assigns them to a string16 . This makes no assumptions about the underlying encoding . This will fail if there are an odd number of bytes in the payload .
bool ReadString16Payload(NtlmBufferReader* reader, base::string16* str) {
  SecurityBuffer sec_buf;
  if (!reader->ReadSecurityBuffer(&sec_buf) || (sec_buf.length % 2 != 0))
    return false;
  std::vector<uint8_t> raw(sec_buf.length);
  if (!reader->ReadBytesFrom(sec_buf, raw))
    return false;
#if defined(ARCH_CPU_BIG_ENDIAN)
  for (size_t i = 0; i < raw.size(); i += 2) {
    std::swap(raw[i], raw[i + 1]);
  }
#endif
  str->assign(reinterpret_cast<const base::char16*>(raw.data()),
              raw.size() / 2);
  return true;
}
bool ReadString16Payload ( NtlmBufferReader * reader , base :: string16 * str ) { SecurityBuffer sec_buf ; if ( ! reader -> ReadSecurityBuffer ( & sec_buf ) || ( sec_buf . length % 2 != 0 ) ) return false ; std :: vector < uint8_t > raw ( sec_buf . length ) ; if ( ! reader -> ReadBytesFrom ( sec_buf , raw ) ) return false ; #if defined ( ARCH_CPU_BIG_ENDIAN ) for ( size_t i = 0 ; i < raw . size ( ) ; i += 2 ) { std :: swap ( raw [ i ] , raw [ i + 1 ] ) ; } #endif str -> assign ( reinterpret_cast < const base :: char16 * > ( raw . data ( ) ) , raw . size ( ) / 2 ) ; return true ; }
Reads bytes from a payload and assigns them to a string16.
Reads bytes from a payload and assigns them to a string16 .