From 430551773fa684cc4ec477df33e5d56d469e1f2a Mon Sep 17 00:00:00 2001 From: Elia Sulimanov Date: Wed, 17 Jun 2020 16:01:37 +0300 Subject: [PATCH] Done EncodingTable api docs --- source/Cosmos.System2/Text/EncodingTable.cs | 52 ++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/source/Cosmos.System2/Text/EncodingTable.cs b/source/Cosmos.System2/Text/EncodingTable.cs index 928b09778..d5148cc9e 100644 --- a/source/Cosmos.System2/Text/EncodingTable.cs +++ b/source/Cosmos.System2/Text/EncodingTable.cs @@ -3,15 +3,24 @@ using System.Text; using Cosmos.Debug.Kernel; namespace Cosmos.System.ExtendedASCII -{ +{ /* * Ideally we should use Dictionary or HashTable here but are yet not working in Cosmos so I have done * this replacement class for now... */ + /// + /// EncodingTable class. Used to manage codepage list. + /// internal static class EncodingTable { + /// + /// Debugger inctanse of the "System" with the "EncodingTable" tag. + /// private static Debugger mDebugger = new Debugger("System", "EncodingTable"); + /// + /// Create new inctanse of the class. + /// static EncodingTable() { mDebugger.SendInternal("Inizializing Encoding Table"); @@ -20,11 +29,25 @@ namespace Cosmos.System.ExtendedASCII Add(858, "IBM0858", new CP858Enconding()); } + /// + /// Struct which used to hold description and encoding. + /// private struct values { + /// + /// Description. + /// public string desc; + /// + /// Encoding. + /// public Encoding encoding; + /// + /// Create new inctanse of the struct. + /// + /// Description. + /// Encoding. public values(string desc, Encoding encoding) { this.desc = desc; @@ -32,19 +55,46 @@ namespace Cosmos.System.ExtendedASCII } }; + /// + /// Max codepage cache size. + /// const int MaxCodepageChacheSize = 2048; + /// + /// Codepage cache. + /// static values[] CodepageCache = new values[MaxCodepageChacheSize]; + /// + /// Add encoding to the encoding table. + /// + /// Codepage. + /// Desciption. + /// Encoding. public static void Add(int codepage, string desc, Encoding encoding) { mDebugger.SendInternal($"Adding codepage {codepage} desc {desc}"); CodepageCache[codepage] = new values(desc, encoding); } + /// + /// Get description, using codepage. + /// + /// Codepage. + /// string value. public static string GetDescription(int codepage) => CodepageCache[codepage].desc; + /// + /// Get encoding, using codepage. + /// + /// Codepage. + /// Encoding value. public static Encoding GetEncoding(int codepage) => CodepageCache[codepage].encoding; + /// + /// Get code page from description. + /// + /// Description. + /// int value, -1 if not found. public static int GetCodePageFromDesc(string desc) { for (int idx = 0; idx < MaxCodepageChacheSize; idx++)