You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Unplugged.IbmBits
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class BinaryWriterExtensionMethods
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Writes the given Unicode string as an 8-bit EBCDIC encoded character string
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void WriteEbcdic(this BinaryWriter writer, string value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var bytes = IbmConverter.GetBytes(value);
|
|
|
|
|
|
writer.Write(bytes);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Writes a big endian encoded Int16 to the stream
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void WriteBigEndian(this BinaryWriter writer, Int16 value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var bytes = IbmConverter.GetBytes(value);
|
|
|
|
|
|
writer.Write(bytes);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Writes a big endian encoded Int32 to the stream
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void WriteBigEndian(this BinaryWriter writer, Int32 value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var bytes = IbmConverter.GetBytes(value);
|
|
|
|
|
|
writer.Write(bytes);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Writes an IBM System/360 Floating Point encoded Single to the stream
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void WriteIbmSingle(this BinaryWriter writer, Single value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var bytes = IbmConverter.GetBytes(value);
|
|
|
|
|
|
writer.Write(bytes);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Writes a packed decimal to the stream
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void WriteIbmPackedDecimal(this BinaryWriter writer, decimal value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var bytes = IbmConverter.GetBytes(value);
|
|
|
|
|
|
writer.Write(bytes);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|