mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
45 lines
983 B
C++
45 lines
983 B
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "config.h"
|
|
#include "core/html/parser/TextResourceDecoder.h"
|
|
|
|
#include "wtf/text/TextCodec.h"
|
|
#include "wtf/text/TextEncodingRegistry.h"
|
|
|
|
namespace blink {
|
|
|
|
TextResourceDecoder::TextResourceDecoder()
|
|
: m_sawError(false)
|
|
{
|
|
}
|
|
|
|
TextResourceDecoder::~TextResourceDecoder()
|
|
{
|
|
}
|
|
|
|
const WTF::TextEncoding& TextResourceDecoder::encoding() const
|
|
{
|
|
return WTF::UTF8Encoding();
|
|
}
|
|
|
|
String TextResourceDecoder::decode(const char* data, size_t len)
|
|
{
|
|
if (!m_codec)
|
|
m_codec = newTextCodec(encoding());
|
|
return m_codec->decode(data, len, WTF::DoNotFlush, false, m_sawError);
|
|
}
|
|
|
|
String TextResourceDecoder::flush()
|
|
{
|
|
if (!m_codec)
|
|
m_codec = newTextCodec(encoding());
|
|
|
|
String result = m_codec->decode(0, 0, WTF::FetchEOF, false, m_sawError);
|
|
m_codec.clear();
|
|
return result;
|
|
}
|
|
|
|
}
|