4#include <system/object.h>
5#include <system/text/decoder_fallback.h>
6#include <system/text/encoder_fallback.h>
7#include <system/text/decoder.h>
8#include <system/text/encoder.h>
9#include <system/text/encoding_decoder.h>
10#include <system/text/encoding_encoder.h>
11#include <system/exceptions.h>
12#include <system/details/array_view.h>
13#include <system/details/stack_array.h>
20 struct EncodingInfoInternal;
37 : m_codepage(codepage)
39 , m_display_name(display_name)
62 const String m_display_name;
76 static constexpr int DEFAULT_CODE_PAGE = 0;
165 virtual ASPOSECPP_SHARED_API
int GetByteCount(System::Details::ArrayView<char_t> chars,
int index,
int count);
171 template<std::
size_t N>
172 int GetByteCount(
const System::Details::StackArray<char_t, N> & chars,
int index,
int count)
174 return GetByteCount(
static_cast<System::Details::ArrayView<char_t>
>(chars), index, count);
189 virtual ASPOSECPP_SHARED_API
int GetByteCount(
const char_t *chars,
int count);
206 virtual ASPOSECPP_SHARED_API
int GetBytes(System::Details::ArrayView<char_t> chars,
int char_index,
int char_count, System::Details::ArrayView<uint8_t> bytes,
int byte_index);
214 template<std::
size_t SC, std::
size_t SB>
215 int GetBytes(System::Details::StackArray<char_t, SC> &chars,
int char_index,
int char_count, System::Details::StackArray<uint8_t, SB> &bytes,
int byte_index)
217 return GetBytes(
static_cast<System::Details::ArrayView<char_t>
>(chars), char_index, char_count,
static_cast<System::Details::ArrayView<uint8_t>
>(bytes), byte_index);
249 template<std::
size_t N>
252 return GetBytes(
static_cast<System::Details::ArrayView<char_t>
>(chars), index, count);
265 virtual ASPOSECPP_SHARED_API
int GetBytes(
const char_t* chars,
int char_count, uint8_t* bytes,
int byte_count);
281 virtual ASPOSECPP_SHARED_API
int GetCharCount(
const uint8_t* bytes,
int count);
307 virtual ASPOSECPP_SHARED_API
int GetChars(
const uint8_t *bytes,
int byte_count, char_t *chars,
int char_count);
328 virtual ASPOSECPP_SHARED_API
String GetString(
const System::Details::ArrayView<uint8_t> &bytes);
332 template<std::
size_t N>
335 return GetString(
static_cast<System::Details::ArrayView<uint8_t>
>(bytes));
349 virtual ASPOSECPP_SHARED_API
String GetString(
const System::Details::ArrayView<uint8_t> &bytes,
int index,
int count);
355 template<std::
size_t N>
358 return GetString(
static_cast<System::Details::ArrayView<uint8_t>
>(bytes), index, count);
435 const Details::EncodingInfoInternal*
m_info;
439 bool m_is_read_only =
true;
454 Encoding(
const Details::EncodingInfoInternal* info);
458 void SetDefaultFallbacks();
460 void VerifyInternalData();
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Encoding services.
Definition: encoding.h:67
virtual int GetByteCount(ArrayPtr< char_t > chars, int index, int count)
Get the number of characters needed to encode a character buffer.
virtual int GetMaxCharCount(int byte_count)=0
Get the maximum number of characters needed to decode a specified number of bytes.
virtual int GetBytes(System::Details::ArrayView< char_t > chars, int char_index, int char_count, System::Details::ArrayView< uint8_t > bytes, int byte_index)
Get the bytes that result from encoding a character buffer.
virtual int GetBytes(ArrayPtr< char_t > chars, int char_index, int char_count, ArrayPtr< uint8_t > bytes, int byte_index)
Get the bytes that result from encoding a character buffer.
virtual ArrayPtr< uint8_t > GetBytes(ArrayPtr< char_t > chars, int index, int count)
Get the bytes that result from encoding a character buffer.
virtual String GetString(const System::Details::ArrayView< uint8_t > &bytes)
Decodes a buffer of bytes into a string.
Encoding(int codepage, const EncoderFallbackPtr &encoder_fallback, const DecoderFallbackPtr &decoder_fallback)
Constructor.
virtual SharedPtr< Object > Clone()
Clones encoding object.
static EncodingPtr GetEncoding(const String &name)
Gets encoding by name.
virtual String GetString(const System::Details::ArrayView< uint8_t > &bytes, int index, int count)
Decodes a buffer of bytes into a string.
virtual bool get_IsBrowserSave()
Checks whether encoding can be used in browser to save content.
ArrayPtr< uint8_t > GetBytes(const System::Details::StackArray< char_t, N > &chars, int index, int count)
Get the bytes that result from encoding a character buffer.
Definition: encoding.h:250
virtual int GetMaxByteCount(int char_count)=0
Get the maximum number of bytes needed to encode a specified number of characters.
virtual int get_WindowsCodePage()
Gets Windows codepage ID.
static EncodingPtr get_BigEndianUnicode()
Gets the standard big-endian Unicode encoding object.
virtual ArrayPtr< char_t > GetChars(ArrayPtr< uint8_t > bytes)
Get the characters that result from decoding a byte buffer.
static EncodingPtr get_UTF8Unmarked()
Only internal, to be used by the class libraries: Unmarked and non-input-validating.
Encoding(int codepage)
Constructor.
virtual ArrayPtr< uint8_t > GetPreamble()
Returns a sequence of bytes that denotes the encoding (e. g. BOM).
virtual String get_BodyName()
Gets mail agent body compatible encoding name.
virtual int GetByteCount(ArrayPtr< char_t > chars)
Get the number of characters needed to encode a character buffer.
virtual bool get_IsMailNewsDisplay()
Checks whether encoding can be used in mail client to display content.
virtual int GetByteCount(System::Details::ArrayView< char_t > chars, int index, int count)
Get the number of characters needed to encode a character buffer.
static EncodingPtr get_UTF7()
Gets the standard UTF-7 encoding object.
const int m_codepage
Code page identifier.
Definition: encoding.h:437
static EncodingPtr GetEncoding(int codepage, const EncoderFallbackPtr &encoder_fallback, const DecoderFallbackPtr &decoder_fallback)
Gets encoding by codepage.
virtual int GetCharCount(const uint8_t *bytes, int count)
Get the number of characters needed to decode a byte buffer.
virtual int get_CodePage()
Gets Windows codepage ID.
virtual String get_HeaderName()
Gets mail agent header compatible encoding name.
System::SharedPtr< Encoding > Ptr
RTTI.
Definition: encoding.h:73
virtual int GetCharCount(ArrayPtr< uint8_t > bytes, int index, int count)
Get the number of characters needed to decode a byte buffer.
Encoding(const Details::EncodingInfoInternal *info)
Internal constructor.
virtual int GetByteCount(const char_t *chars, int count)
Get the number of characters needed to encode a character buffer.
virtual ArrayPtr< uint8_t > GetBytes(const System::Details::ArrayView< char_t > &chars, int index, int count)
Get the bytes that result from encoding a character buffer.
virtual EncoderPtr GetEncoder()
Get an encoder that forwards requests to this object.
static EncodingPtr get_UTF32()
int GetByteCount(const System::Details::StackArray< char_t, N > &chars, int index, int count)
Get the number of characters needed to encode a character buffer.
Definition: encoding.h:172
virtual String get_WebName()
Gets IANA-compatible encoding name.
int GetHashCode() const override
Hashes encoding.
static ArrayPtr< uint8_t > Convert(const EncodingPtr &src_encoding, const EncodingPtr &dst_encoding, const ArrayPtr< uint8_t > &bytes)
Converts bytes between two encodings.
virtual ArrayPtr< uint8_t > GetBytes(const String &s)
Get the bytes that result from encoding a character buffer.
int GetBytes(System::Details::StackArray< char_t, SC > &chars, int char_index, int char_count, System::Details::StackArray< uint8_t, SB > &bytes, int byte_index)
Get the bytes that result from encoding a character buffer.
Definition: encoding.h:215
static EncodingPtr get_BigEndianUTF32()
Gets the standard big-endian UTF-32 encoding object.
static ArrayPtr< EncodingInfoPtr > GetEncodings()
Gets list of known encodings.
static EncodingPtr get_UTF8()
Gets the standard UTF-8 encoding object.
virtual bool get_IsBrowserDisplay()
Checks whether encoding can be used in browser to display content.
void set_EncoderFallback(const EncoderFallbackPtr &value)
Sets encoder fallback.
virtual ArrayPtr< uint8_t > GetBytes(ArrayPtr< char_t > chars)
Get the bytes that result from encoding a character buffer.
virtual ArrayPtr< char_t > GetChars(ArrayPtr< uint8_t > bytes, int index, int count)
Get the characters that result from decoding a byte buffer.
virtual String GetString(uint8_t *bytes, int byte_count)
Decodes a buffer of bytes into a string.
static EncodingPtr get_Latin1()
Gets Latin1 encoding. FOR INTERNAL USE.
virtual String GetString(ArrayPtr< uint8_t > bytes, int index, int count)
Decodes a buffer of bytes into a string.
static EncodingPtr get_Unicode()
Gets the standard Unicode encoding object.
String GetString(System::Details::StackArray< uint8_t, N > bytes, int index, int count)
Decodes a buffer of bytes into a string.
Definition: encoding.h:356
virtual int GetChars(const uint8_t *bytes, int byte_count, char_t *chars, int char_count)
Get the characters that result from decoding a byte buffer.
void set_DecoderFallback(const DecoderFallbackPtr &value)
Sets decoder fallback.
virtual int GetCharCount(ArrayPtr< uint8_t > bytes)
Get the number of characters needed to decode a byte buffer.
const EncoderFallbackPtr get_EncoderFallback() const
Gets encoder fallback.
const Details::EncodingInfoInternal * m_info
Pointer to internal encoding info.
Definition: encoding.h:435
virtual int GetBytes(const char_t *chars, int char_count, uint8_t *bytes, int byte_count)
Get the bytes that result from encoding a character buffer.
static EncodingPtr GetEncoding(int codepage)
Gets encoding by codepage.
virtual bool get_IsMailNewsSave()
Checks whether encoding can be used in mail client to save content.
static EncodingPtr GetEncoding(const String &name, const EncoderFallbackPtr &encoder_fallback, const DecoderFallbackPtr &decoder_fallback)
Gets encoding by name.
static EncodingPtr get_Default()
Gets default encoding.
virtual String get_EncodingName()
Gets human-readable encoding name.
Encoding()
Default constructor.
virtual int GetByteCount(const String &s)
Get the number of characters needed to encode a string.
static EncodingPtr get_ASCII()
Gets ASCII encoding.
bool Equals(SharedPtr< Object > obj) override
Compares encodings.
bool get_IsReadOnly()
Checks whether encoding is read-only.
virtual int GetChars(ArrayPtr< uint8_t > bytes, int byte_index, int byte_count, ArrayPtr< char_t > chars, int char_index)
Get the characters that result from decoding a byte buffer.
String GetString(System::Details::StackArray< uint8_t, N > &bytes)
Decodes a buffer of bytes into a string.
Definition: encoding.h:333
virtual bool get_IsSingleByte()
Checks whether encoding is single byte.
virtual String GetString(ArrayPtr< uint8_t > bytes)
Decodes a buffer of bytes into a string.
DecoderFallbackPtr get_DecoderFallback() const
Gets decoder fallback.
virtual int GetBytes(const String &s, int char_index, int char_count, ArrayPtr< uint8_t > bytes, int byte_index)
Get the bytes that result from encoding a character buffer.
virtual DecoderPtr GetDecoder()
Get a decoder that forwards requests to this object.
static ArrayPtr< uint8_t > Convert(const EncodingPtr &src_encoding, const EncodingPtr &dst_encoding, const ArrayPtr< uint8_t > &bytes, int index, int count)
Converts bytes between two encodings.
Brief info on encoding. Objects of this class should only be allocated using System::MakeObject() fun...
Definition: encoding.h:30
const String & get_Name() const
Gets encoding short name.
Definition: encoding.h:47
int get_CodePage() const
Gets codepage ID.
Definition: encoding.h:44
const String & get_DisplayName() const
Gets full localized encoding name.
Definition: encoding.h:50
EncodingPtr GetEncoding()
Gets encoding described by info.
EncodingInfo(int codepage, const String &name, const String &display_name)
Constuctor.
Definition: encoding.h:36
@ Text
Defines color adjustment information for text.
Definition: db_command.h:9