Class DicomEncoding
Namespace: Aspose.Medical.Common.Text
Assembly: Aspose.Medical.dll (25.11.0)
Handles alternate character sets for DICOM character strings.
public class DicomEncoding : IDicomEncodingInheritance
Implements
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
DicomEncoding()
Initializes a new instance of the Aspose.Medical.Common.Text.DicomEncoding.
protected DicomEncoding()Remarks
Prevent instantiating the class outside Aspose.Medical. The class isn’t static to allow (future, potential) improvements by overriding Encoding/Decoding functionality of this class using inheritance. with minimum changes in the public API.
Fields
Default
Default encoding used in DICOM.
public static readonly Encoding DefaultField Value
Remarks
DICOM Spec 6.2.1.2 (Ideographic and Phonetic Characters in Data Elements with VR of PN) says ISO-IR 6 is default (basic) set. https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html#sect_6.2.1.2 .
Defaults
Default encodings used in DICOM.
public static readonly Encoding[] DefaultsField Value
Encoding []
Remarks
DICOM Spec 6.2.1.2 (Ideographic and Phonetic Characters in Data Elements with VR of PN) says ISO-IR 6 is default (basic) set. https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html#sect_6.2.1.2 .
Properties
Current
The current instance of the Aspose.Medical.Common.Text.DicomEncoding. Read-only, Aspose.Medical.Common.Text.DicomEncoding.
public static IDicomEncoding Current { get; }Property Value
Methods
Decode(Span<byte>, Encoding[], ReadOnlySpan<byte>)
Decodes all the byte fragments in the specified System.Byte array into a System.String
using a set of the given encodings.
public virtual string Decode(Span<byte> data, Encoding[] encodings, ReadOnlySpan<byte> delimiters)Parameters
The System.Byte data to be decoded into a System.String (can be multi-charset).
encodings Encoding
[]
A list of registered encodings that can be used to decode the given data.
delimiters ReadOnlySpan
<
byte
>
Delimiters in text values that reset the encoding.
Returns
A System.String that contains the results of decoding the specified sequence of bytes.
Exceptions
Unknown escape sequence found in the given fragment.
GetByteCount(string, Encoding[], ReadOnlySpan<byte>)
Calculates the number of bytes that encoding all the characters in the specified string would produce, given the same fallback and delimiter logic as your GetBytes method.
public virtual int GetByteCount(string data, Encoding[] encodings, ReadOnlySpan<byte> delimiters)Parameters
data string
The string containing the characters to encode.
encodings Encoding
[]
Encodings used to encode the given data (for final‐fallback).
delimiters ReadOnlySpan
<
byte
>
Delimiters in text values that reset the encoding.
Returns
The total number of bytes that your GetBytes would have returned.
GetBytes(string, Encoding[], byte, ReadOnlySpan<byte>)
Encodes all the characters in the specified string into a System.Byte’s array.
public virtual byte[] GetBytes(string data, Encoding[] encodings, byte paddingValue, ReadOnlySpan<byte> delimiters)Parameters
data string
The string containing the characters to encode.
encodings Encoding
[]
Encodings used to encode the given data.
paddingValue byte
System.Byte value used to pad result System.Byte’s array to even length.
delimiters ReadOnlySpan
<
byte
>
Delimiters in text values that reset the encoding.
Returns
byte []
A System.Byte array containing the results of encoding the specified set of characters.
GetCharset(Encoding, bool)
Get DICOM character set from .NET System.Text.Encoding.
public virtual string GetCharset(Encoding encoding, bool extended = false)Parameters
encoding Encoding
.NET Encoding.
extended bool
If true, the extended version of the character set is returned.
Returns
The System.String Specific Character Set as defined in DICOM.
Exceptions
No character set found for the encoding.
GetEncoding(string)
Returns the System.Text.Encoding corresponding to charset (DICOM Specific Character Set).
public Encoding GetEncoding(string charset)Parameters
charset string
Name of a DICOM character set (encoding).
Returns
The System.Text.Encoding according to the given charset
or Aspose.Medical.Common.Text.DicomEncoding.Default if the encoding is unknown.
Remarks
Allows some common misspellings such as redundant spaces, use of ISO-IR ### or ISO IR ### instead of ISO_IR ###.
GetEncodings(string[])
Returns a collection of System.Text.Encoding corresponding to the given charsets,
where every charsets item is a name of the DICOM Specific Character Set.
public Encoding[] GetEncodings(string[] charsets)Parameters
charsets string
[]
List of DICOM Character Sets.
Returns
Encoding []
The collection of System.Text.Encoding specified in charsets.
RegisterEncoding(string, string)
Registers an encoding for a specific character set value.
public void RegisterEncoding(string charsetName, string encodingName)Parameters
charsetName string
The name of the character set as given in the Specific Character Set DICOM attribute.
encodingName string
The name of .NET encoding for the charsetName.
RegisterProvider(EncodingProvider)
Registers an encoding provider.
public void RegisterProvider(EncodingProvider provider)Parameters
provider EncodingProvider
A subclass of System.Text.EncodingProvider that provides access to additional character encodings. </byte></byte></byte></byte>