/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Script decoding templates for processing byte data as UTF-8 or UTF-16. */
static size_t DecodeInto(const UniquePtr<Decoder>& aDecoder, const Span<const uint8_t>& aSrc,
Span<Utf8Unit> aDest, bool aEndOfSource) {
uint32_t result;
size_t read;
size_t written; // Until C++ char8_t happens, our decoder APIs deal in |uint8_t| while // |Utf8Unit| internally deals with |char|, so there's inevitable impedance // mismatch between |aDest| as |Utf8Unit| and |AsWritableBytes(aDest)| as // |Span<uint8_t>|. :-( The written memory will be interpreted through // |char Utf8Unit::mValue| which is *permissible* because any object's // memory can be interpreted as |char|. Unfortunately, until // twos-complement is mandated, we have to play fast and loose and *hope* // interpreting memory storing |uint8_t| as |char| will pick up the desired // wrapped-around value. ¯\_(ツ)_/¯
std::tie(result, read, written, std::ignore) =
aDecoder->DecodeToUTF8(aSrc, AsWritableBytes(aDest), aEndOfSource);
MOZ_ASSERT(result == kInputEmpty);
MOZ_ASSERT(read == aSrc.Length());
MOZ_ASSERT(written <= aDest.Length());
return written;
}
};
} // namespace mozilla::dom
#endif// mozilla_dom_ScriptDecoding_h
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.