Strange Notepad ++ HEX Editor Plugin

The goal is to write an array of bytes to a file. I have a byte array that matches [] with a few bytes, and then:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace _32_to_16
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] fits = File.ReadAllBytes("1.myf");
            byte[] img = new byte[fits.Length / 2];
            for (int i = 0; i < fits.Length; i += 4) //Drops 2 high bytes
            {
                img[i/2] = fits[i + 2];
                img[i/2 + 1] = fits[i + 3];
            }
            File.WriteAllBytes("new.myf", img);
        }
    }
}

Before writing to the file, img [] has the same values:

  • IMG [0] = 0x31
  • IMG [1] = 0x27
  • IMG [2] = 0x31
  • IMG [3] = 0xe2
  • etc.

After writing to a file, in the HEX editor I see

  • 00000000: 31 27 31 3f and other incorrect values.

Sometimes, with other fits [] values, the img [] array writes the file correctly. What am I doing wrong?
File for test 1.myf (which does incorrect results) https://www.dropbox.com/s/6xyf761oqm8j7y1/1.myf?dl=0 File for test 2.myf (correct entry in the file) https: // www .dropbox.com / s / zrglpx7kmpydurz / 2.myf? dl = 0

I simplified the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace _32_to_16
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] img_correct = new byte[8] { 0xbd, 0x19, 0xbd, 0x72, 0xbd, 0x93, 0xbd, 0xf7 };
            File.WriteAllBytes("img_correct.myf", img_correct);

            byte[] img_strange = new byte[8] { 0x33, 0x08, 0x33, 0xac, 0x33, 0xe3, 0x33, 0x94 };
            File.WriteAllBytes("img_strange.myf", img_strange);
        }
    }
}

HEX- img_correct.myf : bd 19 bd 72 bd 93 bd f7

HEX- img_strange.myf : 33 08 33 3f 3f 3f

+4
3

HEX-Editor Notepad ++, , , .

.

HxD HEX-, as you can see here

+6

":" Unicode: U + EF1A

NotePad ++ ":" " EFBC9A", " EF1A".

UTF8, Unicode.

" EFBC9A" , "벚".

Hex Editor, , UTF8, Hex Editor, sue Unicode Format, UTF8.

, UTF8 Unicode.

: U + EF1A → ":" Windows.

+1

4? , . + = 4 . , , for, () 4.

0
source

All Articles