DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
TextEncoding.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "Common.h"
9#include "System/Object.h"
10#include "System/String.h"
11#include "System/Array.h"
12#include "System/SmartPointer.h"
13
14namespace DotNetDupe {
15 namespace System {
16 namespace Text {
17 class Encoding;
18
21
26 class Encoding : public Object {
27 public:
29 virtual ~Encoding() = default;
30
34 virtual Array<char> GetBytes(const String& s) = 0;
35
39 virtual String GetString(const Array<char>& bytes) = 0;
40
45 virtual String GetString(const char* bytes, int byteCount) = 0;
46 };
47
48 class UTF8Encoding;
49
52
57 class UTF8Encoding : public Encoding {
58 public:
60 Array<char> GetBytes(const String& s) override;
61
63 String GetString(const Array<char>& bytes) override;
64
66 String GetString(const char* bytes, int byteCount) override;
67 };
68
71 class TextEncoding : public Object {
72 public:
76
77 private:
78 static UTF8EncodingPtr s_utf8EncodingInstance;
79 };
80 }
81 }
82}
Provides methods for creating, manipulating, searching, and sorting arrays.
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition Array.h:29
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
Represents a character encoding.
virtual ~Encoding()=default
Virtual destructor.
virtual Array< char > GetBytes(const String &s)=0
Encodes a set of characters from the specified String into a sequence of bytes.
virtual String GetString(const Array< char > &bytes)=0
Decodes a sequence of bytes from the specified byte array into a String.
virtual String GetString(const char *bytes, int byteCount)=0
Decodes a sequence of bytes from the specified buffer into a String.
Provides static access to standard character encodings.
static EncodingPtr UTF8()
Gets an encoding for the UTF-8 format.
Represents a UTF-8 encoding of Unicode characters.
Array< char > GetBytes(const String &s) override
Encodes a set of characters into a sequence of UTF-8 bytes.
String GetString(const Array< char > &bytes) override
Decodes a sequence of UTF-8 bytes into a String.
SmartPointer< UTF8Encoding > UTF8EncodingPtr
SmartPointer alias for UTF8Encoding instances.
SmartPointer< Encoding > EncodingPtr
SmartPointer alias for Encoding instances.