예제 #1
0
        /// <summary>
        /// convert the bytes from ebcdic to ascii. in the case of an unprintable ascii
        /// char, insert the hex value of the ebcdic byte in the output text.
        /// Method is intended for viewing the text value of a byte stream.
        /// </summary>
        /// <param name="Bytes"></param>
        /// <returns></returns>
        public static string EbcdicBytesToPrintableAscii(this byte[] Bytes)
        {
            var sb = new StringBuilder();

            global::System.Text.Encoding encoding =
                global::System.Text.Encoding.GetEncoding(37);
            var text = encoding.GetString(Bytes);

            for (int ix = 0; ix < text.Length; ++ix)
            {
                var ch1 = text[ix];
                if (ch1.IsPrintable())
                {
                    sb.Append(ch1);
                }
                else
                {
                    var b1 = Bytes[ix];
                    var s1 = '/' + b1.ToHex() + ' ';
                    sb.SpaceSeparatorAppend(s1);
                }
            }

            return(sb.ToString());
        }
예제 #2
0
        private static void GetString(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);
            ENCODING encoding = NSJSKeyValueCollection.Get <ENCODING>(arguments.This);

            if (encoding == null)
            {
                Throwable.ObjectDisposedException(arguments.VirtualMachine);
            }
            else
            {
                string s = null;
                if (arguments.Length > 0)
                {
                    NSJSUInt8Array chars = arguments[0] as NSJSUInt8Array;
                    if (chars != null)
                    {
                        byte[] buffer = chars.Buffer;
                        if (buffer != null)
                        {
                            NSJSInt32 index = null;
                            NSJSInt32 len   = null;
                            switch (arguments.Length)
                            {
                            case 2:
                                len = arguments[1] as NSJSInt32;
                                break;

                            case 3:
                                index = arguments[1] as NSJSInt32;
                                len   = arguments[2] as NSJSInt32;
                                break;
                            }
                            int ofs   = index != null ? index.Value : 0;
                            int count = len != null ? len.Value : buffer.Length;
                            if (count < 0)
                            {
                                count = 0;
                            }
                            if (ofs < 0)
                            {
                                ofs = 0;
                            }
                            s = encoding.GetString(buffer, ofs, count);
                        }
                    }
                }
                if (s != null)
                {
                    arguments.SetReturnValue(s);
                }
                else
                {
                    arguments.SetReturnValue(NSJSValue.Undefined(arguments.VirtualMachine));
                }
            }
        }
예제 #3
0
    internal string method_7(global::System.IO.Stream stream_0)
    {
        ushort num = this.method_3(stream_0);

        byte[] array = new byte[(int)num];
        for (int i = 0; i < (int)num; i++)
        {
            byte b = (byte)stream_0.ReadByte();
            array[i] = b;
        }
        global::System.Text.Encoding utf = global::System.Text.Encoding.UTF8;
        return(utf.GetString(array));
    }
예제 #4
0
        private string method_0(global::System.IO.MemoryStream memoryStream_0)
        {
            byte[] array = new byte[2];
            memoryStream_0.Read(array, 0, 2);
            if (global::System.BitConverter.IsLittleEndian)
            {
                global::System.Array.Reverse(array);
            }
            short num = global::System.BitConverter.ToInt16(array, 0);

            byte[] array2 = new byte[(int)num];
            memoryStream_0.Read(array2, 0, (int)num);
            global::System.Text.Encoding utf = global::System.Text.Encoding.UTF8;
            return(utf.GetString(array2));
        }
예제 #5
0
 /// <summary>
 /// 結合したデータを変換して文字列として返す
 /// </summary>
 /// <example>
 /// string s = builder.Convert(Encoding.GetEncoding("Shift_JIS"));
 /// </example>
 /// <param name="CodePage"></param>
 /// <returns></returns>
 public string Convert(global::System.Text.Encoding codePage)
 {
     return(codePage.GetString(ListHelper <byte> .ConvertToArray(data)));
 }