none
Write Hex value into hex file RRS feed

  • Question

  • Hello, I would like to ask a question.

    i have string a = "FFFFFF"

    I write it to a file.

    When I look in hex editor, I see FF FF FF in hex value but in string it is "ÿÿÿ"

    How to do like that?



    • Edited by Peppyrotom Saturday, October 3, 2015 1:38 AM
    Saturday, October 3, 2015 1:37 AM

Answers

  • How are you writing it?

    Here is an example:

    My.Computer.FileSystem.WriteAllText("D:\ForumTEST.txt", "FFFFFF", False, New ASCIIEncoding)
    yields this:

            Dim b() As Byte = {&HFF, &HFF, &HFF, &HFF, &HFF, &HFF}
            My.Computer.FileSystem.WriteAllBytes("D:\ForumTEST.txt", b, False)

    yields this:

    Saturday, October 3, 2015 12:58 PM

All replies

  • When I look in hex editor, I see FF FF FF in hex value but in string it is "ÿÿÿ"

    How to do like that?

    The string "FFFFFF" is 46 46 46 46 46 46 in hex.   If you are seeing FF FF FF in the hex editor then you are interpreting that string as a hex sequence and writing the bytes.  The string equivalent could be displayed as "ÿÿÿ" (depending on your hex editor).   If that's not what you want to see in the file then you need to change the code you are using to write your string. For instance, you might want to write your string as a string instead of as a sequence of byte values.


    • Edited by Acamar Saturday, October 3, 2015 3:32 AM sp
    Saturday, October 3, 2015 3:32 AM
  • i have string a = "FFFFFF"

    I write it to a file.

    When I look in hex editor, I see FF FF FF in hex value but in string it is "ÿÿÿ"

    How to do like that?

    Why don't you give us something with which to work? Such as telling us exactly how you're
    writing it to the file. Show us your code.

    >How to do like that?

    How to do like what? You've said what you see, but you haven't said what you want to see.

    You also need to explain *exactly* what you mean by a "hex file".

    - Wayne

    Saturday, October 3, 2015 4:10 AM
  • How are you writing it?

    Here is an example:

    My.Computer.FileSystem.WriteAllText("D:\ForumTEST.txt", "FFFFFF", False, New ASCIIEncoding)
    yields this:

            Dim b() As Byte = {&HFF, &HFF, &HFF, &HFF, &HFF, &HFF}
            My.Computer.FileSystem.WriteAllBytes("D:\ForumTEST.txt", b, False)

    yields this:

    Saturday, October 3, 2015 12:58 PM