1 // Copyright 2018 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FXCRT_CFX_UTF8ENCODER_H_ 8 #define CORE_FXCRT_CFX_UTF8ENCODER_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/fx_memory_wrappers.h" 13 #include "core/fxcrt/fx_string.h" 14 15 class CFX_UTF8Encoder { 16 public: 17 CFX_UTF8Encoder(); 18 ~CFX_UTF8Encoder(); 19 20 void Input(wchar_t unicodeAsWchar); 21 22 // The data returned by GetResult() is invalidated when this is modified by 23 // appending any data. GetResult()24 ByteStringView GetResult() const { 25 return ByteStringView(m_Buffer.data(), m_Buffer.size()); 26 } 27 28 private: 29 std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_Buffer; 30 }; 31 32 #endif // CORE_FXCRT_CFX_UTF8ENCODER_H_ 33