From fd7cede17e027a83de2aff3bc0f5ee875271e444 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 9 Aug 2018 21:32:47 +0000 Subject: Move all utf8 decoding under fx_string.h Put encoder in cfx_utf8encoder.{h,cpp} to parallel decoder. Add tests, and fix one corner case involving 0xff. Change-Id: Ib97540afdc708bcc6280a79c76734ec68ea72690 Reviewed-on: https://pdfium-review.googlesource.com/39770 Commit-Queue: Lei Zhang Reviewed-by: Lei Zhang --- core/fxcrt/cfx_utf8encoder.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/fxcrt/cfx_utf8encoder.h (limited to 'core/fxcrt/cfx_utf8encoder.h') diff --git a/core/fxcrt/cfx_utf8encoder.h b/core/fxcrt/cfx_utf8encoder.h new file mode 100644 index 0000000000..d44a829108 --- /dev/null +++ b/core/fxcrt/cfx_utf8encoder.h @@ -0,0 +1,31 @@ +// Copyright 2018 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXCRT_CFX_UTF8ENCODER_H_ +#define CORE_FXCRT_CFX_UTF8ENCODER_H_ + +#include + +#include "core/fxcrt/fx_string.h" + +class CFX_UTF8Encoder { + public: + CFX_UTF8Encoder(); + ~CFX_UTF8Encoder(); + + void Input(wchar_t unicodeAsWchar); + + // The data returned by GetResult() is invalidated when this is modified by + // appending any data. + ByteStringView GetResult() const { + return ByteStringView(m_Buffer.data(), m_Buffer.size()); + } + + private: + std::vector m_Buffer; +}; + +#endif // CORE_FXCRT_CFX_UTF8ENCODER_H_ -- cgit v1.2.3